Delikatne zmiany w strukturze PAK. signed char zamiast short
This commit is contained in:
parent
b4f6d3a85a
commit
a84a69cbd6
12 changed files with 330 additions and 73 deletions
|
|
@ -38,7 +38,7 @@ CreateCargo::~CreateCargo() {
|
|||
//-----------------------------------------------------------------------------
|
||||
// Punk wejœcia do tworzenia archivum
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CreateCargo::Create(const std::string& path, const int16_t& flag)
|
||||
bool CreateCargo::Create(const std::string& path, const short& flag)
|
||||
{
|
||||
cargoFile = path + "." + extension;
|
||||
catalogPath = path;
|
||||
|
|
@ -111,29 +111,37 @@ bool CreateCargo::GetFileList(const std::string& path)
|
|||
else
|
||||
{
|
||||
std::string fileRef = RemoveStartPath(PathToUnixLike(tmpPath));
|
||||
PathConf pc;
|
||||
if (methodFlags > -1)
|
||||
|
||||
if (fileRef.length() > 255)
|
||||
{
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
pc.parameter = methodFlags;
|
||||
filesPaths.push_back(pc);
|
||||
std::cerr << "The file path is too long. It exceeds 255 characters." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!FindOnTheList(ignoreList, fileRef) || !CheckFileExtension(fileRef, ignoreList))
|
||||
PathConf pc;
|
||||
if (methodFlags > -1)
|
||||
{
|
||||
if (FindOnTheList(zipList, fileRef) || CheckFileExtension(fileRef, zipList))
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 3 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 2 : 0;
|
||||
}
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
std::cout << pc.path << " - " << pc.parameter << std::endl;
|
||||
pc.parameter = methodFlags;
|
||||
filesPaths.push_back(pc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!FindOnTheList(ignoreList, fileRef) || !CheckFileExtension(fileRef, ignoreList))
|
||||
{
|
||||
if (FindOnTheList(zipList, fileRef) || CheckFileExtension(fileRef, zipList))
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? FILE_FLAG_ZIPENC : FILE_FLAG_COMPRESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? FILE_FLAG_ENCRYPT : FILE_FLAG_RAW;
|
||||
}
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
std::cout << pc.path << " - " << pc.parameter << std::endl;
|
||||
filesPaths.push_back(pc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -186,7 +194,7 @@ CargoHead CreateCargo::CreateCargoHead(const uint32_t& filesLen, const uint64_t&
|
|||
//-----------------------------------------------------------------------------
|
||||
// Sprawdza czy plik znajduje siê na liœcie
|
||||
//-----------------------------------------------------------------------------
|
||||
void CreateCargo::computingBytes(const int16_t& flag, std::vector<char>& input, std::vector<char>& output)
|
||||
void CreateCargo::computingBytes(const int8_t& flag, std::vector<char>& input, std::vector<char>& output)
|
||||
{
|
||||
//Flaga aktywna sprawdza czy plik jest na liœcie. Jeœli jest to zwraca surowedane
|
||||
//Przeciwnie kompresuje dane
|
||||
|
|
@ -194,19 +202,19 @@ void CreateCargo::computingBytes(const int16_t& flag, std::vector<char>& input,
|
|||
|
||||
switch (flag)
|
||||
{
|
||||
case 1:
|
||||
case FILE_FLAG_COMPRESS:
|
||||
output = cm.chunked(input, true, false);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case FILE_FLAG_ENCRYPT:
|
||||
output = cm.chunked(input, false, true);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case FILE_FLAG_ZIPENC:
|
||||
output = cm.chunked(input, true, true);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case FILE_FLAG_RAW:
|
||||
output = cm.chunked(input, false, false);
|
||||
break;
|
||||
|
||||
|
|
@ -245,7 +253,7 @@ std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
|
|||
|
||||
if (size > MAX_FILE_SIZE)
|
||||
{
|
||||
std::cerr << path << " is too large. It exceeds 2GB!" << std::endl;
|
||||
std::cerr << path << " is too large. It exceeds " << MAX_FILE_SIZE / 1024 / 1024 / 1024 << "GB!" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -255,7 +263,7 @@ std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
|
|||
f.close();
|
||||
|
||||
//Tworzenie hashu CRC
|
||||
const uint64_t crc = XXH64(buffer.data(), buffer.size(), VERSION);
|
||||
const uint64_t crc = XXH64(buffer.data(), buffer.size(), 0);
|
||||
|
||||
//Kompresjia
|
||||
std::vector<char> pakBuffer;
|
||||
|
|
@ -267,7 +275,7 @@ std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
|
|||
ft.hashName = fnv64(path);
|
||||
ft.offset = offset;
|
||||
ft.size = pakBuffer.size();
|
||||
ft.flag = file.parameter;
|
||||
ft.flag = static_cast<int8_t>(file.parameter);
|
||||
ft.crc = crc;
|
||||
|
||||
cargo.write(reinterpret_cast<const char*>(pakBuffer.data()), pakBuffer.size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue