RMG-Core: remove usage of PATH_MAX in Archive.cpp and use our own define

This commit is contained in:
Rosalie Wanders
2025-03-09 18:45:28 +01:00
parent 950becc1b3
commit 249654a879
+7 -6
View File
@@ -34,6 +34,7 @@
//
#define UNZIP_READ_SIZE 67108860 /* 64 MiB */
#define UNZIP_FILENAME_LEN 4096
//
// Local Functions
@@ -155,11 +156,11 @@ CORE_EXPORT bool CoreReadZipFile(std::filesystem::path file, std::filesystem::pa
for (uint64_t i = 0; i < zipInfo.number_entry; i++)
{
unz_file_info fileInfo;
char fileName[PATH_MAX];
char fileName[UNZIP_FILENAME_LEN];
// if we can't retrieve file info,
// skip the file
if (unzGetCurrentFileInfo(zipFile, &fileInfo, fileName, PATH_MAX, nullptr, 0, nullptr, 0) != UNZ_OK)
if (unzGetCurrentFileInfo(zipFile, &fileInfo, fileName, UNZIP_FILENAME_LEN, nullptr, 0, nullptr, 0) != UNZ_OK)
{
continue;
}
@@ -319,7 +320,7 @@ CORE_EXPORT bool CoreRead7zipFile(std::filesystem::path file, std::filesystem::p
for (uint32_t i = 0; i < db.NumFiles; i++)
{
size_t filename_size = 0;
uint16_t fileName[PATH_MAX];
uint16_t fileName[UNZIP_FILENAME_LEN];
// skip directories
if (SzArEx_IsDir(&db, i))
@@ -329,7 +330,7 @@ CORE_EXPORT bool CoreRead7zipFile(std::filesystem::path file, std::filesystem::p
// skip when filename size exceeds our buffer size
filename_size = SzArEx_GetFileNameUtf16(&db, i, nullptr);
if (filename_size > PATH_MAX)
if (filename_size > UNZIP_FILENAME_LEN)
{
continue;
}
@@ -474,10 +475,10 @@ CORE_EXPORT bool CoreUnzip(std::filesystem::path file, std::filesystem::path pat
for (uint64_t i = 0; i < zipInfo.number_entry; i++)
{
unz_file_info fileInfo;
char fileName[PATH_MAX];
char fileName[UNZIP_FILENAME_LEN];
// ensure we can retrieve the current file info
if (unzGetCurrentFileInfo(zipFile, &fileInfo, fileName, PATH_MAX, nullptr, 0, nullptr, 0) != UNZ_OK)
if (unzGetCurrentFileInfo(zipFile, &fileInfo, fileName, UNZIP_FILENAME_LEN, nullptr, 0, nullptr, 0) != UNZ_OK)
{
unzClose(zipFile);
error = "CoreUnzip: unzGetCurrentFileInfo Failed!";