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

directory: use vlc_loaddir instead of vlc_readdir

This makes the input thread much less responsive. But there is no other
way to enable directory sorting.
parent db19221d
...@@ -70,6 +70,8 @@ struct directory_t ...@@ -70,6 +70,8 @@ struct directory_t
directory_t *parent; directory_t *parent;
DIR *handle; DIR *handle;
char *uri; char *uri;
char **filev;
int filec, i;
#ifdef HAVE_OPENAT #ifdef HAVE_OPENAT
dev_t device; dev_t device;
ino_t inode; ino_t inode;
...@@ -88,6 +90,12 @@ struct access_sys_t ...@@ -88,6 +90,12 @@ struct access_sys_t
char *xspf_ext; char *xspf_ext;
}; };
/* Select non-hidden files only */
static int visible (const char *name)
{
return name[0] != '.';
}
/***************************************************************************** /*****************************************************************************
* Open: open the directory * Open: open the directory
*****************************************************************************/ *****************************************************************************/
...@@ -132,6 +140,10 @@ int DirInit (access_t *p_access, DIR *handle) ...@@ -132,6 +140,10 @@ int DirInit (access_t *p_access, DIR *handle)
root->parent = NULL; root->parent = NULL;
root->handle = handle; root->handle = handle;
root->uri = uri; root->uri = uri;
root->filec = vlc_loaddir (handle, &root->filev, visible, NULL);
if (root->filec < 0)
root->filev = NULL;
root->i = 0;
#ifdef HAVE_OPENAT #ifdef HAVE_OPENAT
struct stat st; struct stat st;
if (fstat (dirfd (handle), &st)) if (fstat (dirfd (handle), &st))
...@@ -194,6 +206,9 @@ void DirClose( vlc_object_t * p_this ) ...@@ -194,6 +206,9 @@ void DirClose( vlc_object_t * p_this )
p_sys->current = current->parent; p_sys->current = current->parent;
closedir (current->handle); closedir (current->handle);
free (current->uri); free (current->uri);
while (current->i < current->filec)
free (current->filev[current->i++]);
free (current->filev);
#ifndef HAVE_OPENAT #ifndef HAVE_OPENAT
free (current->path); free (current->path);
#endif #endif
...@@ -239,12 +254,12 @@ block_t *DirBlock (access_t *p_access) ...@@ -239,12 +254,12 @@ block_t *DirBlock (access_t *p_access)
return block; return block;
} }
char *entry = vlc_readdir (current->handle); if (current->i >= current->filec)
if (entry == NULL)
{ /* End of directory, go back to parent */ { /* End of directory, go back to parent */
closedir (current->handle); closedir (current->handle);
p_sys->current = current->parent; p_sys->current = current->parent;
free (current->uri); free (current->uri);
free (current->filev);
#ifndef HAVE_OPENAT #ifndef HAVE_OPENAT
free (current->path); free (current->path);
#endif #endif
...@@ -282,12 +297,7 @@ block_t *DirBlock (access_t *p_access) ...@@ -282,12 +297,7 @@ block_t *DirBlock (access_t *p_access)
return NULL; return NULL;
} }
/* Skip current, parent and hidden directories */ char *entry = current->filev[current->i++];
if (entry[0] == '.')
{
free (entry);
return NULL;
}
/* Handle recursion */ /* Handle recursion */
if (p_sys->mode != MODE_COLLAPSE) if (p_sys->mode != MODE_COLLAPSE)
...@@ -336,6 +346,10 @@ block_t *DirBlock (access_t *p_access) ...@@ -336,6 +346,10 @@ block_t *DirBlock (access_t *p_access)
} }
sub->parent = current; sub->parent = current;
sub->handle = handle; sub->handle = handle;
sub->filec = vlc_loaddir (handle, &sub->filev, visible, NULL);
if (sub->filec < 0)
sub->filev = NULL;
sub->i = 0;
#ifdef HAVE_OPENAT #ifdef HAVE_OPENAT
sub->device = st.st_dev; sub->device = st.st_dev;
sub->inode = st.st_ino; sub->inode = st.st_ino;
......
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