This commit is contained in:
yanczi 2025-10-24 13:26:36 +02:00
parent 8b9a1789ab
commit 729cb13ff8
8 changed files with 71 additions and 10 deletions

View file

@ -224,7 +224,7 @@ std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
f.close(); f.close();
//Tworzenie hashu CRC //Tworzenie hashu CRC
uint64_t crc = XXH64(buffor.data(), buffor.size(), VERSION); uint32_t crc = crc32(buffor);
//Kompresjia //Kompresjia
std::vector<char> zip; std::vector<char> zip;
@ -331,6 +331,16 @@ uint64_t CreateCargo::fnv64(const std::string& data)
return hash; return hash;
} }
//-----------------------------------------------------------------------------
// Wygenerój CRC32 HASH integralnoœci
//-----------------------------------------------------------------------------
uint32_t CreateCargo::crc32(const std::vector<char>& buffer)
{
boost::crc_32_type crc;
crc.process_bytes(buffer.data(), buffer.size());
return crc.checksum();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Sprawdzanie czy plik znajduje się na liście // Sprawdzanie czy plik znajduje się na liście
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -30,6 +30,7 @@
#include <utility> #include <utility>
#include <memory> #include <memory>
#include <string> #include <string>
#include <boost/crc.hpp>
#include "DataStruct.h" #include "DataStruct.h"
#include "Txtpp.h" #include "Txtpp.h"
@ -122,6 +123,9 @@ private:
// Wygenerój FNV-1a HASH // Wygenerój FNV-1a HASH
uint64_t fnv64(const std::string& data); uint64_t fnv64(const std::string& data);
// CRC
uint32_t crc32(const std::vector<char>&);
// Rozdzielanie paternu od œcie¿ki // Rozdzielanie paternu od œcie¿ki
void ExtPatternAndPathDetection(const std::vector<std::string>&, std::vector<std::string>&, std::vector<std::string>&); void ExtPatternAndPathDetection(const std::vector<std::string>&, std::vector<std::string>&, std::vector<std::string>&);

View file

@ -21,7 +21,7 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <boost/crc.hpp>
#define EXTENSION "pak" #define EXTENSION "pak"
@ -62,6 +62,6 @@ struct FilesTable
uint64_t hashName; uint64_t hashName;
uint64_t offset; uint64_t offset;
uint32_t size; uint32_t size;
uint64_t crc; uint32_t crc;
uint8_t isZip; uint8_t isZip;
}; };

View file

@ -114,9 +114,9 @@ bool ExtractCargo::CheckCargoFile()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Sprawdzanie sumy kontrolnej // Sprawdzanie sumy kontrolnej
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool ExtractCargo::HashValid(const std::vector<char>& data, const uint64_t& crc) bool ExtractCargo::HashValid(const std::vector<char>& data, const uint32_t& crc)
{ {
uint64_t actualCrc = XXH64(data.data(), data.size(), VERSION); uint32_t actualCrc = crc32(data);
if (actualCrc != crc) if (actualCrc != crc)
{ {
@ -126,6 +126,16 @@ bool ExtractCargo::HashValid(const std::vector<char>& data, const uint64_t& crc)
return true; return true;
} }
//-----------------------------------------------------------------------------
// Wygenerój CRC32 HASH integralnoœci
//-----------------------------------------------------------------------------
uint32_t ExtractCargo::crc32(const std::vector<char>& buffer)
{
boost::crc_32_type crc;
crc.process_bytes(buffer.data(), buffer.size());
return crc.checksum();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Pobieranie nagłówków plików // Pobieranie nagłówków plików
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -28,6 +28,7 @@
#include <sstream> #include <sstream>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <boost/crc.hpp>
#include "DataStruct.h" #include "DataStruct.h"
#include "xxhash.h" #include "xxhash.h"
@ -68,7 +69,10 @@ private:
void LoadFilesTable(); void LoadFilesTable();
// Sprawdzanie sumy kontrolnej // Sprawdzanie sumy kontrolnej
bool HashValid(const std::vector<char>&, const uint64_t&); bool HashValid(const std::vector<char>&, const uint32_t&);
// CRC
uint32_t crc32(const std::vector<char>&);
// Utwórz katalog // Utwórz katalog
void CreateDirections(std::filesystem::path); void CreateDirections(std::filesystem::path);

View file

@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

12
license/lz4/LICENSE.txt Normal file
View file

@ -0,0 +1,12 @@
This repository uses 2 different licenses :
- all files in the `lib` directory use a BSD 2-Clause license
- all other files use a GPL-2.0-or-later license, unless explicitly stated otherwise
Relevant license is reminded at the top of each source file,
and with presence of COPYING or LICENSE file in associated directories.
This model is selected to emphasize that
files in the `lib` directory are designed to be included into 3rd party applications,
while all other files, in `programs`, `tests` or `examples`,
are intended to be used "as is", as part of their intended scenarios,
with no intention to support 3rd party integration use cases.

View file

@ -104,7 +104,7 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>3rd\ftxui\include;3rd\lz4\include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>3rd\crc\include;3rd\ftxui\include;3rd\lz4\include</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -122,7 +122,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>3rd\ftxui\include;3rd\lz4\include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>3rd\crc\include;3rd\ftxui\include;3rd\lz4\include</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -138,7 +138,6 @@
<ClCompile Include="Interface.cpp" /> <ClCompile Include="Interface.cpp" />
<ClCompile Include="ViewCargo.cpp" /> <ClCompile Include="ViewCargo.cpp" />
<ClCompile Include="voidcmd.cpp" /> <ClCompile Include="voidcmd.cpp" />
<ClCompile Include="xxhash.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CompressingManager.h" /> <ClInclude Include="CompressingManager.h" />
@ -148,7 +147,6 @@
<ClInclude Include="Interface.h" /> <ClInclude Include="Interface.h" />
<ClInclude Include="Txtpp.h" /> <ClInclude Include="Txtpp.h" />
<ClInclude Include="ViewCargo.h" /> <ClInclude Include="ViewCargo.h" />
<ClInclude Include="xxhash.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="icon.ico" /> <Image Include="icon.ico" />