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

Jean-Baptiste Kempf <[email protected]> Mon, 19 Apr 2021 19:44:17 +0200
Newsgroups gmane.comp.video.videolan.libdvdcss.devel
Message-ID <[email protected]>
--===============2461988185988426293==
Content-Type: multipart/alternative;
 boundary="--==_mimepart_607dc17170b15_d555a8200031636a9";
 charset=UTF-8
Content-Transfer-Encoding: 7bit


----==_mimepart_607dc17170b15_d555a8200031636a9
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit



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.



----==_mimepart_607dc17170b15_d555a8200031636a9--

--===============2461988185988426293==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbGliZHZkY3Nz
LWRldmVsIG1haWxpbmcgbGlzdApsaWJkdmRjc3MtZGV2ZWxAdmlkZW9sYW4ub3JnCmh0dHBzOi8v
bWFpbG1hbi52aWRlb2xhbi5vcmcvbGlzdGluZm8vbGliZHZkY3NzLWRldmVsCg==

--===============2461988185988426293==--