From f6c4c19b022a50328e7315888e3a64b0cc3021d8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 14 Apr 2021 22:12:15 +0200 Subject: [PATCH] - added a filter to the directory loader to remove EDuke32's texture cache files. These cause problems with the texture manager. --- source/common/filesystem/file_directory.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/common/filesystem/file_directory.cpp b/source/common/filesystem/file_directory.cpp index 4f2c94eba..8c7b57876 100644 --- a/source/common/filesystem/file_directory.cpp +++ b/source/common/filesystem/file_directory.cpp @@ -154,13 +154,28 @@ int FDirectory::AddDirectory(const char *dirpath) } else { - if (strstr(fi, ".orig") || strstr(fi, ".bak")) + if (strstr(fi, ".orig") || strstr(fi, ".bak") || strstr(fi, ".cache")) { // We shouldn't add backup files to the file system continue; } size_t size = 0; FString fn = FString(dirpath) + fi; + + // The next one is courtesy of EDuke32. :( + // Putting cache files in the application directory is very bad style. + // Unfortunately, having a garbage file named "texture" present will cause serious problems down the line. + if (!stricmp(fi, "textures")) + { + FILE* f = fopen(fn, "rb"); + if (f) + { + char check[3]{}; + fread(check, 1, 3, f); + if (!memcmp(check, "LZ4", 3)) continue; + } + } + if (GetFileInfo(fn, &size, nullptr)) { AddEntry(fn, (int)size);