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

file: use the same open() path for directories as for regular files

This requires support for fdopendir(). One open() and fstat() calls per
input file are avoided. Ok, this is not such a major improvement).
This should also work around brain-damaged file system drivers such as
Linux HFS+, whereby opendir() succeeds on regular files.
parent 09775b17
......@@ -568,7 +568,7 @@ dnl Check for system libs needed
need_libc=false
dnl Check for usual libc functions
AC_CHECK_FUNCS([ctime_r daemon fcntl fork getenv getpwuid_r gettimeofday isatty lstat memalign posix_fadvise posix_madvise posix_memalign putenv setenv stricmp strnicmp tdestroy uselocale])
AC_CHECK_FUNCS([ctime_r daemon fcntl fdopendir fork getenv getpwuid_r gettimeofday isatty lstat memalign posix_fadvise posix_madvise posix_memalign putenv setenv stricmp strnicmp tdestroy uselocale])
AC_REPLACE_FUNCS([asprintf atof atoll getcwd getpid gmtime_r lldiv localtime_r rewind strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab vasprintf])
AC_CHECK_FUNCS(fdatasync,,
[AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
......
......@@ -177,8 +177,15 @@ int Open( vlc_object_t *p_this )
* how to parse the data. The directory plugin will do it. */
if (S_ISDIR (st.st_mode))
{
#ifdef HAVE_FDOPENDIR
DIR *handle = fdopendir (fd);
if (handle == NULL)
goto error; /* Uh? */
return DirInit (p_access, handle);
#else
msg_Dbg (p_access, "ignoring directory");
goto error;
#endif
}
access_sys_t *p_sys = malloc (sizeof (*p_sys));
......@@ -235,6 +242,13 @@ error:
void Close (vlc_object_t * p_this)
{
access_t *p_access = (access_t*)p_this;
if (p_access->pf_read == NULL)
{
DirClose (p_this);
return;
}
access_sys_t *p_sys = p_access->p_sys;
close (p_sys->fd);
......
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