Commit f467427e authored by Gildas Bazin's avatar Gildas Bazin

* src/misc/modules.c, modules/access/directory.c: Win32 fixes...

* src/misc/modules.c, modules/access/directory.c: Win32 fixes (GetFileAttributes() returns -1 on error).
parent efe2b1ad
......@@ -129,15 +129,19 @@ static int Open( vlc_object_t *p_this )
!S_ISDIR( stat_info.st_mode ) )
#elif defined(WIN32)
int i_ret;
# ifdef UNICODE
wchar_t pwsz_path[MAX_PATH];
mbstowcs( pwsz_path, p_access->psz_path, MAX_PATH );
pwsz_path[MAX_PATH-1] = 0;
if( !(GetFileAttributes( pwsz_path ) & FILE_ATTRIBUTE_DIRECTORY) )
wchar_t psz_path[MAX_PATH];
mbstowcs( psz_path, p_access->psz_path, MAX_PATH );
psz_path[MAX_PATH-1] = 0;
# else
if( !(GetFileAttributes( p_access->psz_path ) & FILE_ATTRIBUTE_DIRECTORY) )
char *psz_path = p_access->psz_path;
# endif
i_ret = GetFileAttributes( psz_path );
if( i_ret == -1 || !(i_ret & FILE_ATTRIBUTE_DIRECTORY) )
#else
if( strcmp( p_access->psz_access, "dir") &&
strcmp( p_access->psz_access, "directory") )
......
......@@ -820,7 +820,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
char psz_path[MAX_PATH + 256];
WIN32_FIND_DATA finddata;
HANDLE handle;
unsigned int rc;
int rc;
#else
int i_dirlen;
DIR * dir;
......@@ -838,13 +838,13 @@ static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
MultiByteToWideChar( CP_ACP, 0, psz_dir, -1, psz_wdir, MAX_PATH );
rc = GetFileAttributes( psz_wdir );
if( !(rc & FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
if( rc<0 || !(rc&FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
/* Parse all files in the directory */
swprintf( psz_wpath, L"%ls\\*", psz_wdir );
#else
rc = GetFileAttributes( psz_dir );
if( !(rc & FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
if( rc<0 || !(rc&FILE_ATTRIBUTE_DIRECTORY) ) return; /* Not a directory */
#endif
/* Parse all files in the directory */
......
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