[libdvdcss-devel] [Git][videolan/libdvdcss][master] Fix opening non-ASCII paths in Windows

Jean-Baptiste Kempf gitlab at videolan.org
Mon Apr 19 17:44:17 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdcss


Commits:
17ec0256 by Petri Hintukainen at 2021-04-19T17:48:14+03:00
Fix opening non-ASCII paths in Windows

- - - - -


1 changed file:

- src/device.c


Changes:

=====================================
src/device.c
=====================================
@@ -63,6 +63,10 @@
 #   include <fcntl.h>                                           /* O_BINARY  */
 #endif
 
+#ifdef _WIN32
+#   include <windows.h>
+#endif
+
 #include "dvdcss/dvdcss.h"
 
 #include "common.h"
@@ -442,7 +446,22 @@ int dvdcss_close_device ( dvdcss_t dvdcss )
  *****************************************************************************/
 static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
 {
+#ifdef _WIN32
+    int wlen;
+    dvdcss->i_fd = -1;
+    wlen = MultiByteToWideChar( CP_UTF8, 0, psz_device, -1, NULL, 0 );
+    if( wlen > 0 ) {
+        wchar_t *wpath = (wchar_t*)malloc( sizeof(wchar_t) * wlen );
+        if( wpath ) {
+            if( MultiByteToWideChar(CP_UTF8, 0, psz_device, -1, wpath, wlen ) ) {
+                dvdcss->i_fd = _wopen( wpath, O_BINARY );
+            }
+            free( wpath );
+        }
+    }
+#else
     dvdcss->i_fd = open( psz_device, O_BINARY );
+#endif
 
     if( dvdcss->i_fd == -1 )
     {



View it on GitLab: https://code.videolan.org/videolan/libdvdcss/-/commit/17ec02569acb40c13b8b3329faf027ec62676af0

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdcss/-/commit/17ec02569acb40c13b8b3329faf027ec62676af0
You're receiving this email because of your account on code.videolan.org.




More information about the libdvdcss-devel mailing list