Skip to content

Commit

Permalink
C4Group: Fix C4Group::Open failing to open directories as st_size of …
Browse files Browse the repository at this point in the history
…a directory is 0
  • Loading branch information
Fulgen301 committed Sep 24, 2024
1 parent 1a12cf2 commit 2a27121
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/C4Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2a27121

Please sign in to comment.