Commit c24028b1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: pack vlc_DIR

parent 3a6e6558
...@@ -112,9 +112,12 @@ int vlc_mkdir( const char *dirname, mode_t mode ) ...@@ -112,9 +112,12 @@ int vlc_mkdir( const char *dirname, mode_t mode )
* when called with an empty argument or just '\'. */ * when called with an empty argument or just '\'. */
typedef struct vlc_DIR typedef struct vlc_DIR
{ {
_WDIR *p_real_dir; _WDIR *wdir; /* MUST be first, see <vlc_fs.h> */
int i_drives; union
bool b_insert_back; {
DWORD drives;
bool insert_dot_dot;
} u;
} vlc_DIR; } vlc_DIR;
...@@ -130,26 +133,25 @@ DIR *vlc_opendir (const char *dirname) ...@@ -130,26 +133,25 @@ DIR *vlc_opendir (const char *dirname)
|| (wcscmp (wpath, L"\\") == 0)) || (wcscmp (wpath, L"\\") == 0))
{ {
/* Special mode to list drive letters */ /* Special mode to list drive letters */
p_dir->p_real_dir = NULL; p_dir->wdir = NULL;
#ifdef UNDER_CE #ifdef UNDER_CE
p_dir->i_drives = 1; p_dir->u.drives = 1;
#else #else
p_dir->i_drives = GetLogicalDrives (); p_dir->u.drives = GetLogicalDrives ();
#endif #endif
return (void *)p_dir; return (void *)p_dir;
} }
_WDIR *p_real_dir = _wopendir (wpath); _WDIR *wdir = _wopendir (wpath);
if (p_real_dir == NULL) if (wdir == NULL)
{ {
free (p_dir); free (p_dir);
return NULL; return NULL;
} }
p_dir->p_real_dir = p_real_dir; p_dir->wdir = wdir;
assert (wpath[0]); // wpath[1] is defined assert (wpath[0]); // wpath[1] is defined
p_dir->b_insert_back = !wcscmp (wpath + 1, L":\\"); p_dir->u.insert_dot_dot = !wcscmp (wpath + 1, L":\\");
return (void *)p_dir; return (void *)p_dir;
} }
...@@ -157,20 +159,20 @@ char *vlc_readdir (DIR *dir) ...@@ -157,20 +159,20 @@ char *vlc_readdir (DIR *dir)
{ {
vlc_DIR *p_dir = (vlc_DIR *)dir; vlc_DIR *p_dir = (vlc_DIR *)dir;
if (p_dir->p_real_dir == NULL) if (p_dir->wdir == NULL)
{ {
/* Drive letters mode */ /* Drive letters mode */
DWORD drives = p_dir->i_drives; DWORD drives = p_dir->u.drives;
if (drives == 0) if (drives == 0)
return NULL; /* end */ return NULL; /* end */
#ifdef UNDER_CE #ifdef UNDER_CE
p_dir->i_drives = 0; p_dir->u.drives = 0;
return strdup ("\\"); return strdup ("\\");
#else #else
unsigned int i; unsigned int i;
for (i = 0; !(drives & 1); i++) for (i = 0; !(drives & 1); i++)
drives >>= 1; drives >>= 1;
p_dir->i_drives &= ~(1UL << i); p_dir->u.drives &= ~(1UL << i);
assert (i < 26); assert (i < 26);
char *ret; char *ret;
...@@ -180,14 +182,14 @@ char *vlc_readdir (DIR *dir) ...@@ -180,14 +182,14 @@ char *vlc_readdir (DIR *dir)
#endif #endif
} }
if (p_dir->b_insert_back) if (p_dir->u.insert_dot_dot)
{ {
/* Adds "..", gruik! */ /* Adds "..", gruik! */
p_dir->b_insert_back = false; p_dir->u.insert_dot_dot = false;
return strdup (".."); return strdup ("..");
} }
struct _wdirent *ent = _wreaddir (p_dir->p_real_dir); struct _wdirent *ent = _wreaddir (p_dir->wdir);
if (ent == NULL) if (ent == NULL)
return NULL; return NULL;
return FromWide (ent->d_name); return FromWide (ent->d_name);
......
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