Skip to content

Commit

Permalink
fixed some filesystem issues with directories and compression.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Dec 17, 2023
1 parent 1299a37 commit 860a0c2
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 13 deletions.
6 changes: 3 additions & 3 deletions source/common/filesystem/source/file_directory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int FDirectory::AddDirectory(const char *dirpath, LumpFilterInfo* filter, FileSy
else
{
mBasePath = nullptr;
AllocateEntries(list.size());
AllocateEntries((int)list.size());
for(auto& entry : list)
{
if (mBasePath == nullptr)
Expand All @@ -122,7 +122,7 @@ int FDirectory::AddDirectory(const char *dirpath, LumpFilterInfo* filter, FileSy
}


if (filter->filenamecheck == nullptr || filter->filenamecheck(fi.c_str(), entry.FilePath.c_str()))
if (filter == nullptr || filter->filenamecheck == nullptr || filter->filenamecheck(fi.c_str(), entry.FilePath.c_str()))
{
if (entry.Length > 0x7fffffff)
{
Expand All @@ -131,7 +131,7 @@ int FDirectory::AddDirectory(const char *dirpath, LumpFilterInfo* filter, FileSy
}
// for internal access we use the normalized form of the relative path.
Entries[count].FileName = NormalizeFileName(entry.FilePathRel.c_str());
Entries[count].Length = entry.Length;
Entries[count].CompressedSize = Entries[count].Length = entry.Length;
Entries[count].Flags = RESFF_FULLPATH;
Entries[count].ResourceID = -1;
Entries[count].Method = METHOD_STORED;
Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/source/file_grp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static bool OpenGrp(FResourceFile* file, LumpFilterInfo* filter)
for(uint32_t i = 0; i < NumLumps; i++)
{
Entries[i].Position = Position;
Entries[i].Length = LittleLong(fileinfo[i].Size);
Entries[i].CompressedSize = Entries[i].Length = LittleLong(fileinfo[i].Size);
Position += fileinfo[i].Size;
Entries[i].Flags = 0;
Entries[i].Namespace = ns_global;
Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/source/file_hog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static bool OpenHog(FResourceFile* rf, LumpFilterInfo* filter)

FResourceEntry Entry;
Entry.Position = Reader->Tell();
Entry.Length = elength;
Entry.CompressedSize = Entry.Length = elength;
Entry.Flags = 0;
Entry.CRC32 = 0;
Entry.Namespace = ns_global;
Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/source/file_lump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static bool OpenLump(FResourceFile* file, LumpFilterInfo*)
Entries[0].Namespace = ns_global;
Entries[0].ResourceID = -1;
Entries[0].Position = 0;
Entries[0].Length = file->GetContainerReader()->GetLength();
Entries[0].CompressedSize = Entries[0].Length = file->GetContainerReader()->GetLength();
Entries[0].Method = METHOD_STORED;
Entries[0].Flags = 0;
return true;
Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/source/file_mvl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static bool OpenMvl(FResourceFile* rf, LumpFilterInfo* filter)
uint32_t elength = Reader->ReadUInt32();

Entries[i].Position = pos;
Entries[i].Length = elength;
Entries[i].CompressedSize = Entries[i].Length = elength;
Entries[i].ResourceID = -1;
Entries[i].FileName = rf->NormalizeFileName(name);

Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/source/file_pak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static bool OpenPak(FResourceFile* file, LumpFilterInfo* filter)
for(uint32_t i = 0; i < NumLumps; i++)
{
Entries[i].Position = LittleLong(fileinfo[i].filepos);
Entries[i].Length = LittleLong(fileinfo[i].filelen);
Entries[i].CompressedSize = Entries[i].Length = LittleLong(fileinfo[i].filelen);
Entries[i].Flags = RESFF_FULLPATH;
Entries[i].Namespace = ns_global;
Entries[i].ResourceID = -1;
Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/source/file_rff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static bool OpenRFF(FResourceFile* file, LumpFilterInfo*)
for (uint32_t i = 0; i < NumLumps; ++i)
{
Entries[i].Position = LittleLong(lumps[i].FilePos);
Entries[i].Length = LittleLong(lumps[i].Size);
Entries[i].CompressedSize = Entries[i].Length = LittleLong(lumps[i].Size);
Entries[i].Flags = 0;
Entries[i].Method = METHOD_STORED;
if (lumps[i].Flags & 0x10)
Expand Down
4 changes: 2 additions & 2 deletions source/common/filesystem/source/file_ssi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static bool OpenSSI(FResourceFile* file, int version, int EntryCount, LumpFilter
int flength = Reader->ReadInt32();

Entries[i].Position = j;
Entries[i].Length = flength;
Entries[i].CompressedSize = Entries[i].Length = flength;
Entries[i].Flags = 0;
Entries[i].Namespace = ns_global;
Entries[i].Method = METHOD_STORED;
Expand All @@ -76,7 +76,7 @@ static bool OpenSSI(FResourceFile* file, int version, int EntryCount, LumpFilter
std::swap(fn[strlength - 1], fn[strlength - 3]);

Entries[i + 1].Position = j;
Entries[i + 1].Length = flength;
Entries[i + 1].CompressedSize = Entries[i + 1].Length = flength;
Entries[i + 1].Flags = 0;
Entries[i + 1].Namespace = ns_global;
Entries[i + 1].ResourceID = -1;
Expand Down
11 changes: 10 additions & 1 deletion source/common/filesystem/source/file_wad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,22 @@ bool FWadFile::Open(LumpFilterInfo*, FileSystemMessageFunc Printf)

Entries[i].FileName = nullptr;
Entries[i].Position = isBigEndian ? BigLong(fileinfo[i].FilePos) : LittleLong(fileinfo[i].FilePos);
Entries[i].Length = isBigEndian ? BigLong(fileinfo[i].Size) : LittleLong(fileinfo[i].Size);
Entries[i].CompressedSize = Entries[i].Length = isBigEndian ? BigLong(fileinfo[i].Size) : LittleLong(fileinfo[i].Size);

Entries[i].Namespace = ns_global;
Entries[i].Flags = ishigh? RESFF_SHORTNAME | RESFF_COMPRESSED : RESFF_SHORTNAME;
Entries[i].Method = ishigh == 1? METHOD_LZSS : METHOD_STORED;
Entries[i].FileName = stringpool->Strdup(n);
// This doesn't set up the namespace yet.
}
for (uint32_t i = 0; i < NumLumps; i++)
{
if (Entries[i].Method == METHOD_LZSS)
{
// compressed size is implicit.
Entries[i].CompressedSize = (i == NumLumps - 1 ? Reader.GetLength() : Entries[i + 1].Position) - Entries[i].Position;
}
}


GenerateHash(); // Do this before the lump processing below.
Expand Down
2 changes: 1 addition & 1 deletion source/common/filesystem/source/file_whres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool OpenWHRes(FResourceFile* file, LumpFilterInfo*)
std::string synthname = BaseName + num;

Entries[i].Position = offset;
Entries[i].Length = length;
Entries[i].CompressedSize = Entries[i].Length = length;
Entries[i].Flags = RESFF_FULLPATH;
Entries[i].Namespace = ns_global;
Entries[i].ResourceID = -1;
Expand Down

0 comments on commit 860a0c2

Please sign in to comment.