From 2a271217b5626f8b5bbd8081ce7ce357eb8b102c Mon Sep 17 00:00:00 2001 From: George Tokmaji Date: Tue, 24 Sep 2024 13:22:08 +0200 Subject: [PATCH] C4Group: Fix C4Group::Open failing to open directories as st_size of a directory is 0 --- src/C4Group.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/C4Group.cpp b/src/C4Group.cpp index d72a5aa2..53ae78bc 100644 --- a/src/C4Group.cpp +++ b/src/C4Group.cpp @@ -80,9 +80,9 @@ int iC4GroupRewindFilePtrNoWarn = 0; namespace { - bool FileExistsNonEmpty(const char *filePath) + bool ItemExistsNonEmpty(const char *filePath) { - return FileSize(filePath) > 0; + return DirectoryExists(filePath) || FileSize(filePath) > 0; } } @@ -267,7 +267,7 @@ bool C4Group_PackDirectoryTo(const char *szFilename, const char *szFilenameTo) // Check file type if (!DirectoryExists(szFilename)) return false; // Target mustn't exist - if (FileExistsNonEmpty(szFilenameTo)) return false; + if (ItemExistsNonEmpty(szFilenameTo)) return false; // Ignore if (C4Group_TestIgnore(szFilename)) return true; @@ -673,7 +673,7 @@ bool C4Group::Open(const char *szGroupName, bool fCreate) SReplaceChar(szGroupNameN, '\\', DirectorySeparator); // Real reference - if (FileExistsNonEmpty(szGroupNameN)) + if (ItemExistsNonEmpty(szGroupNameN)) { // Init Init();