diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-12-15 17:05:12 -0300 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-04-18 14:27:26 +0200 |
commit | 44989bc95754b40f4c00f10db43ed91f64a3e475 (patch) | |
tree | 97746d3bdd7fb5ee94bb76d24d805e4d8a8783f2 /drivers/windows | |
parent | 30181322447ed02baccc1c9494a8373be5459134 (diff) |
Test and warn of case mismatch on Windows
Will throw a warning when a file is opened with a different case than what is stored on the Windows filesystem.
Diffstat (limited to 'drivers/windows')
-rw-r--r-- | drivers/windows/file_access_windows.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 23c8ea2ec7..d4b8a8c361 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -78,6 +78,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { /* pretty much every implementation that uses fopen as primary backend supports utf8 encoding */ + struct _stat st; if (_wstat(path.c_str(), &st) == 0) { @@ -85,6 +86,23 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { return ERR_FILE_CANT_OPEN; }; +#ifdef TOOLS_ENABLED + if (p_mode_flags==READ) { + WIN32_FIND_DATAW d = {0}; + HANDLE f = FindFirstFileW(filename.c_str(),&d); + if (f) { + String fname = d.cFileName; + if (fname!=String()) { + + String base_file = filename.get_file(); + if (base_file!=fname && base_file.findn(fname)==0) { + WARN_PRINTS("Case mismatch opening file '"+base_file+"', stored as '"+fname+"' in the filesystem. This file will not open when exported to other platforms."); + } + } + FindClose(f); + } + } +#endif if (is_backup_save_enabled() && p_mode_flags & WRITE && !(p_mode_flags & READ)) { save_path = path; path = path + ".tmp"; |