From a93a9406308147db6e1f3705083bad1afd587f82 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Thu, 3 Jul 2025 17:59:20 +0300 Subject: [PATCH] Fix hot-reload files not getting cleaned up during startup Implements minimal required filter support for `FileSystem::DirectoryGetFiles` in order to support removing hot-reload files on Linux/Apple systems. --- .../Engine/Platform/Unix/UnixFileSystem.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Platform/Unix/UnixFileSystem.cpp b/Source/Engine/Platform/Unix/UnixFileSystem.cpp index ceca4cb28..1fb47f0f5 100644 --- a/Source/Engine/Platform/Unix/UnixFileSystem.cpp +++ b/Source/Engine/Platform/Unix/UnixFileSystem.cpp @@ -348,7 +348,9 @@ bool UnixFileSystem::getFilesFromDirectoryTop(Array& results, const char // Validate with filter const int32 fullPathLength = StringUtils::Length(fullPath); const int32 searchPatternLength = StringUtils::Length(searchPattern); - if (searchPatternLength == 0 || StringUtils::Compare(searchPattern, "*") == 0) + if (searchPatternLength == 0 || + StringUtils::Compare(searchPattern, "*") == 0 || + StringUtils::Compare(searchPattern, "*.*") == 0) { // All files } @@ -356,9 +358,26 @@ bool UnixFileSystem::getFilesFromDirectoryTop(Array& results, const char { // Path ending } + else if (searchPattern[0] == '*' && searchPatternLength > 2 && searchPattern[searchPatternLength-1] == '*') + { + // Contains pattern + bool match = false; + for (int32 i = 0; i < pathLength - searchPatternLength - 1; i++) + { + int32 len = Math::Min(searchPatternLength - 2, pathLength - i); + if (StringUtils::Compare(&entry->d_name[i], &searchPattern[1], len) == 0) + { + match = true; + break; + } + } + if (!match) + continue; + } else { // TODO: implement all cases in a generic way + LOG(Warning, "DirectoryGetFiles: Wildcard filter is not implemented"); continue; }