From 87b5a56ddfa70b094e0655f20e4226b46fcb40f1 Mon Sep 17 00:00:00 2001 From: Sofox Date: Fri, 5 Apr 2024 21:38:48 +0100 Subject: [PATCH] Fix duplicated folder reference in Godot Editor after changing filename case --- editor/editor_file_system.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 516b8f3d7451..51e1c27070b6 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1367,6 +1367,10 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector String f = ProjectSettings::get_singleton()->localize_path(p_file); + // Note: Only checks if base directory is case sensitive. + Ref dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + bool fs_case_sensitive = dir->is_case_sensitive("res://"); + if (!f.begins_with("res://")) { return false; } @@ -1390,9 +1394,16 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector int idx = -1; for (int j = 0; j < fs->get_subdir_count(); j++) { - if (fs->get_subdir(j)->get_name() == path[i]) { - idx = j; - break; + if (fs_case_sensitive) { + if (fs->get_subdir(j)->get_name() == path[i]) { + idx = j; + break; + } + } else { + if (fs->get_subdir(j)->get_name().to_lower() == path[i].to_lower()) { + idx = j; + break; + } } }