# HG changeset patch # User Markus Mützel # Date 1569082169 -7200 # Node ID def608acdfa93d2bdf931cc20167300a82d47d32 # Parent 910737d416055c4c7d0e95531961c40bed8d669a Canonicalize case of file path on Windows file systems (bug #56267). * file-ops.cc (canonicalize_file_name): Call GetLongPathNameW to get actual letter case of file name and path. diff -r 910737d41605 -r def608acdfa9 liboctave/system/file-ops.cc --- a/liboctave/system/file-ops.cc Mon Oct 14 17:33:24 2019 -0700 +++ b/liboctave/system/file-ops.cc Sat Sep 21 18:09:29 2019 +0200 @@ -32,6 +32,9 @@ #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) # include #endif +#if defined (OCTAVE_USE_WINDOWS_API) +# include +#endif #include @@ -704,6 +707,17 @@ std::replace (retval.begin (), retval.end (), '/', '\\'); #endif +#if defined (OCTAVE_USE_WINDOWS_API) + // Get a more canonical name wrt case and full names + std::wstring w_tmp = L"\\\\?\\" + u8_to_wstring (retval); + wchar_t w_long[32767] = L""; + int w_len = GetLongPathNameW (w_tmp.c_str (), w_long, 32767); + if (w_len > 4) + retval = u8_from_wstring (std::wstring (w_long+4, w_len-4)); + if (retval[1] == ':') + retval[0] = toupper (retval[0]); +#endif + if (retval.empty ()) msg = std::strerror (errno);