Skip to content
Snippets Groups Projects

Fix opening non-ASCII paths in Windows

Merged Petri Hintukainen requested to merge hpi/libdvdcss:win32-open-fix into master
1 file
+ 19
0
Compare changes
  • Side-by-side
  • Inline
+ 19
0
@@ -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 )
{
Loading