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