]> git.sesse.net Git - vlc/commitdiff
- unicode.c: possible fix for UTF8 filename support under WinMe/98/95, needs testing...
authorDamien Fouilleul <damienf@videolan.org>
Mon, 1 May 2006 10:41:00 +0000 (10:41 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Mon, 1 May 2006 10:41:00 +0000 (10:41 +0000)
src/misc/unicode.c

index 1be8703440c961366d1f785bbd127fd0cac02e18..8b9faa844cb794beefee7c1c42fa3a0f9e3d6146 100644 (file)
@@ -331,11 +331,28 @@ FILE *utf8_fopen( const char *filename, const char *mode )
     }
     wpath[MAX_PATH] = L'\0';
 
-    /*
-     * fopen() cannot open files with non-“ANSI” characters on Windows.
-     * We use _wfopen() instead. Same thing for mkdir() and stat().
-     */
-    return _wfopen( wpath, wmode );
+    /* retrieve OS version */
+    if( GetVersion() < 0x80000000 )
+    {
+       /* for Windows NT and above */
+       /*
+        * fopen() cannot open files with non-“ANSI” characters on Windows.
+        * We use _wfopen() instead. Same thing for mkdir() and stat().
+        */
+       return _wfopen( wpath, wmode );
+    }
+    else
+    {
+       /* for Windows Me/98/95 */
+       /* we use GetShortFileNameW to get the DOS 8.3 version of the file we need to open */
+       char spath[MAX_PATH + 1];
+       if( GetShortPathNameW( wpath, spath, MAX_PATH ) )
+       {
+           return fopen( spath, wmode );
+       }
+       errno = ENOENT;
+       return NULL;
+    }
 #endif
 }
 
@@ -517,7 +534,24 @@ static int utf8_statEx( const char *filename, void *buf,
     }
     wpath[MAX_PATH] = L'\0';
 
-    return _wstati64( wpath, (struct _stati64 *)buf );
+    /* retrieve Windows OS version */
+    if( GetVersion() < 0x80000000 )
+    {
+       /* for Windows NT and above */
+       return _wstati64( wpath, (struct _stati64 *)buf );
+    }
+    else
+    {
+       /* for Windows Me/98/95 */
+       /* we use GetShortFileNameW to get the DOS 8.3 version */
+       char spath[MAX_PATH + 1];
+       if( GetShortPathNameW( wpath, spath, MAX_PATH ) )
+       {
+           return _stati64( spath, (struct _stati64 *)buf );
+       }
+       errno = ENOENT;
+       return -1;
+    }
 #endif
 }