Commit 21a146d2 authored by Thomas Guillem's avatar Thomas Guillem

file: use fdopendir to open a dir from a fd

parent dd0ff262
...@@ -54,18 +54,17 @@ struct access_sys_t ...@@ -54,18 +54,17 @@ struct access_sys_t
}; };
/***************************************************************************** /*****************************************************************************
* Open: open the directory * DirInit: Init the directory access with a directory stream
*****************************************************************************/ *****************************************************************************/
int DirOpen (vlc_object_t *p_this) int DirInit (access_t *p_access, DIR *p_dir)
{ {
access_t *p_access = (access_t*)p_this;
DIR *p_dir;
char *psz_base_uri; char *psz_base_uri;
if (!p_access->psz_filepath) if (!p_access->psz_filepath)
return VLC_EGENERIC; return VLC_EGENERIC;
p_dir = vlc_opendir (p_access->psz_filepath); if (!p_dir)
p_dir = vlc_opendir (p_access->psz_filepath);
if (p_dir == NULL) if (p_dir == NULL)
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -98,6 +97,14 @@ int DirOpen (vlc_object_t *p_this) ...@@ -98,6 +97,14 @@ int DirOpen (vlc_object_t *p_this)
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*****************************************************************************
* DirOpen: Open the directory access
*****************************************************************************/
int DirOpen (vlc_object_t *p_this)
{
return DirInit ((access_t*)p_this, NULL);
}
/***************************************************************************** /*****************************************************************************
* Close: close the target * Close: close the target
*****************************************************************************/ *****************************************************************************/
......
...@@ -205,8 +205,12 @@ int FileOpen( vlc_object_t *p_this ) ...@@ -205,8 +205,12 @@ int FileOpen( vlc_object_t *p_this )
if (S_ISDIR (st.st_mode)) if (S_ISDIR (st.st_mode))
{ {
#ifdef HAVE_FDOPENDIR #ifdef HAVE_FDOPENDIR
close(fd); DIR *p_dir = fdopendir(fd);
return DirOpen (VLC_OBJECT(p_access)); if (!p_dir) {
msg_Err (p_access, "fdopendir error: %s", vlc_strerror_c(errno));
goto error;
}
return DirInit (p_access, p_dir);
#else #else
msg_Dbg (p_access, "ignoring directory"); msg_Dbg (p_access, "ignoring directory");
goto error; goto error;
......
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