Commit 08936b3b authored by Rafaël Carré's avatar Rafaël Carré

Unicode support in directory access on windows. Patch by xxcv. Untested.

parent e77b5163
...@@ -416,7 +416,17 @@ void *vlc_opendir_wrapper( const char *psz_path ) ...@@ -416,7 +416,17 @@ void *vlc_opendir_wrapper( const char *psz_path )
return (void *)p_dir; return (void *)p_dir;
} }
p_real_dir = opendir( psz_path ); if (GetVersion() < 0x80000000)
{
/* for Windows NT and above */
wchar_t wpath[MAX_PATH + 1];
if (!MultiByteToWideChar (CP_UTF8, 0, psz_path, -1, wpath, MAX_PATH))
return NULL;
wpath[MAX_PATH] = L'\0';
p_real_dir = _wopendir( wpath );
}
if ( p_real_dir == NULL ) if ( p_real_dir == NULL )
return NULL; return NULL;
...@@ -445,7 +455,7 @@ struct dirent *vlc_readdir_wrapper( void *_p_dir ) ...@@ -445,7 +455,7 @@ struct dirent *vlc_readdir_wrapper( void *_p_dir )
return &p_dir->dd_dir; return &p_dir->dd_dir;
} }
return readdir( p_dir->p_real_dir ); return _wreaddir( p_dir->p_real_dir );
} }
/* Drive letters mode */ /* Drive letters mode */
...@@ -471,7 +481,7 @@ int vlc_closedir_wrapper( void *_p_dir ) ...@@ -471,7 +481,7 @@ int vlc_closedir_wrapper( void *_p_dir )
if ( p_dir->p_real_dir != NULL ) if ( p_dir->p_real_dir != NULL )
{ {
int i_ret = closedir( p_dir->p_real_dir ); int i_ret = _wclosedir( p_dir->p_real_dir );
free( p_dir ); free( p_dir );
return i_ret; return i_ret;
} }
......
...@@ -429,7 +429,11 @@ int utf8_mkdir( const char *dirname ) ...@@ -429,7 +429,11 @@ int utf8_mkdir( const char *dirname )
void *utf8_opendir( const char *dirname ) void *utf8_opendir( const char *dirname )
{ {
/* TODO: support for WinNT non-ACP filenames */
#if defined (UNDER_CE) || defined (WIN32)
DIR *dir = vlc_opendir_wrapper( dirname );
return dir;
#else
const char *local_name = ToLocale( dirname ); const char *local_name = ToLocale( dirname );
if( local_name != NULL ) if( local_name != NULL )
...@@ -440,6 +444,8 @@ void *utf8_opendir( const char *dirname ) ...@@ -440,6 +444,8 @@ void *utf8_opendir( const char *dirname )
} }
else else
errno = ENOENT; errno = ENOENT;
#endif
return NULL; return NULL;
} }
...@@ -452,7 +458,11 @@ char *utf8_readdir( void *dir ) ...@@ -452,7 +458,11 @@ char *utf8_readdir( void *dir )
if( ent == NULL ) if( ent == NULL )
return NULL; return NULL;
#if defined (UNDER_CE) || defined (WIN32)
return FromWide(ent->d_name);
#else
return vlc_fix_readdir( ent->d_name ); return vlc_fix_readdir( ent->d_name );
#endif
} }
static int dummy_select( const char *str ) static int dummy_select( const char *str )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment