IterateDirectory does not work with folders starting with

I’m using Rama’s code to iterate directories for files. If a directory starts with two or more periods it always returns zero files from IterateDirectory. For instance a directory “…aaaaBBB” would not work.

static FORCEINLINE bool GetFiles(const FString& FullPathOfBaseDir, TArray<FString>& FilenamesOut, bool Recursive, const FString& FilterByExtension) {
	const FString FileExt = FilterByExtension.Replace(TEXT("."), TEXT("")).ToLower();
	FString Str;
	auto FilenamesVisitor = MakeDirectoryVisitor(
		[&](const TCHAR* FilenameOrDirectory, bool bIsDirectory) {
		if (!bIsDirectory) {
			if (FileExt != "") {
				Str = FPaths::GetCleanFilename(FilenameOrDirectory);
				if (FPaths::GetExtension(Str).ToLower() == FileExt) {
					if (Recursive) {
						FilenamesOut.Push(FilenameOrDirectory); //need whole path for recursive
					} else {
						FilenamesOut.Push(Str);
					}
				}
			} else {
				Str = FPaths::GetCleanFilename(FilenameOrDirectory);
				if (Recursive) {
					FilenamesOut.Push(FilenameOrDirectory); //need whole path for recursive
				} else {
					FilenamesOut.Push(Str);
				}
			}
		}
		return true;
	}
	);
	if (Recursive) {
		return FPlatformFileManager::Get().GetPlatformFile().IterateDirectoryRecursively(*FullPathOfBaseDir, FilenamesVisitor);
	} else {
		return FPlatformFileManager::Get().GetPlatformFile().IterateDirectory(*FullPathOfBaseDir, FilenamesVisitor);
	}
}

Have you tried to debug this function and see where path gets incorrect values?

Just out of curiosity, why would you name a directory with a bunch of dots?

I checked down the line and think it’s happening in WindowsPlatformFile.cpp but I’m no expert on their code.

I found out while working on a file browser interface. Checking to make sure everything lined up I found out I already have a folder named …something and spent forever trying to figure out why all folders weren’t showing up until I tracked it down to the IterateDirectory and periods.