Abdelrazak Younes wrote:
The comment was correct in a latin world and for pre Win2000 system (Win9x). AFAIK since Win2000, the filesystem uses utf16 so there is no such thing as 8bit encoding. Provided that we don't support Win9x I'd prefer that we switch to the wide version.

Somethink like this? and then dropping the A version?
But we should not apply it for 1.6.

Peter
Index: support/os_win32.cpp
===================================================================
--- support/os_win32.cpp        (revision 26731)
+++ support/os_win32.cpp        (working copy)
@@ -23,12 +23,16 @@
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/ExceptionMessage.h"
-
+#include "support/qstring_helpers.h"
 #include "support/lassert.h"
 
 #include <cstdlib>
 #include <vector>
 
+#include <QString>
+#include <QFile>
+
+
 /* The GetLongPathName macro may be defined on the compiling machine,
  * but we must use a bit of trickery if the resulting executable is
  * to run on a Win95 machine.
@@ -204,21 +208,32 @@
 
 static string const get_long_path(string const & short_path)
 {
-       // GetLongPathName needs the path in file system encoding.
-       // We can use to_local8bit, since file system encoding and the
-       // local 8 bit encoding are identical on windows.
+       DWORD result;
+       QString qlong_path;
+
+QT_WA({
+       vector<wchar_t> long_path(MAX_PATH);
+       result = GetLongPathNameW((wchar_t *)toqstr(short_path).utf16(), 
+                                                                               
&long_path[0], long_path.size());
+       qlong_path = QString::fromUtf16((const unsigned short*)&long_path[0]);
+} , {
        vector<char> long_path(MAX_PATH);
-       DWORD result = 
GetLongPathName(to_local8bit(from_utf8(short_path)).c_str(),
-                                      &long_path[0], long_path.size());
+       result = GetLongPathNameA(to_local8bit(from_utf8(short_path)).c_str(),
+                                                                               
&long_path[0], long_path.size());
+       qlong_path = QFile::decodeName(&long_path[0]);
+});
 
+       // MAX_PATH should be big enougt!
+       /*
        if (result > long_path.size()) {
                long_path.resize(result);
                result = GetLongPathName(short_path.c_str(),
                                         &long_path[0], long_path.size());
-               LASSERT(result <= long_path.size(), /**/);
+               LASSERT(result <= long_path.size(), );
        }
+       */
 
-       return (result == 0) ? short_path : 
to_utf8(from_filesystem8bit(&long_path[0]));
+       return (result == 0) ? short_path : fromqstr(qlong_path);
 }
 
 

Reply via email to