]> git.sesse.net Git - vlc/commitdiff
Support filenames outside the ANSI Code Page
authorRémi Denis-Courmont <rem@videolan.org>
Wed, 1 Nov 2006 21:03:53 +0000 (21:03 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Wed, 1 Nov 2006 21:03:53 +0000 (21:03 +0000)
modules/access/file.c

index 4d4b667cafc35c10803cf812011cf7ecedd651a9..03953fc402f082fa697358dc08237a51f93de3e3 100644 (file)
@@ -445,17 +445,35 @@ static int open_file (access_t *p_access, const char *psz_name)
     p_access->info.i_update |= INPUT_UPDATE_SIZE;
     fseek( p_sys->fd, 0, SEEK_SET );
 #else
-    const char *psz_localname = ToLocale (path);
-    if (psz_localname == NULL)
+    int fd = -1;
+
+# if defined (WIN32)
+    if (GetVersion() < 0x80000000)
     {
-        msg_Err (p_access, "incorrect file name %s", psz_name);
-        free (path);
-        return -1;
+        /* for Windows NT and above */
+        wchar_t wpath[MAX_PATH + 1];
+        if (!MultiByteToWideChar (CP_UTF8, 0, path, -1, wpath, MAX_PATH))
+        {
+            msg_Err (p_access, "incorrect file name %s", psz_name);
+            return VLC_EGENERIC;
+        }
+        wpath[MAX_PATH] = L'\0'; 
+        fd = _wopen( wpath, O_NONBLOCK );
     }
+    else
+# endif
+    {
+        const char *psz_localname = ToLocale (path);
+        if (psz_localname == NULL)
+        {
+            msg_Err (p_access, "incorrect file name %s", psz_name);
+            free (path);
+            return -1;
+        }
 
-    // FIXME: support non-ANSI filenames on Win32
-    int fd = open (path, O_NONBLOCK /*| O_LARGEFILE*/);
-    LocaleFree (psz_localname);
+        fd = open (path, O_NONBLOCK /*| O_LARGEFILE*/);
+        LocaleFree (psz_localname);
+    }
     free (path);
 
     if (fd == -1)