/*****************************************************************************
* directory.c: expands a directory (directory: access plug-in)
*****************************************************************************
- * Copyright (C) 2002-2008 the VideoLAN team
+ * Copyright (C) 2002-2008 VLC authors and VideoLAN
* $Id$
*
* Authors: Derk-Jan Hartman <hartman at videolan dot org>
* RĂ©mi Denis-Courmont
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#include <sys/types.h>
#include <sys/stat.h>
+#include <errno.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
# include <fcntl.h>
-#elif defined( WIN32 ) && !defined( UNDER_CE )
+#elif defined( WIN32 )
# include <io.h>
#endif
uri = NULL;
}
else
- uri = make_URI (p_access->psz_filepath, "file");
+ uri = vlc_path2uri (p_access->psz_filepath, "file");
if (unlikely(uri == NULL))
goto error;
if (unlikely(len == -1))
goto fatal;
- block_t *block = block_heap_Alloc (footer, footer, len);
+ block_t *block = block_heap_Alloc (footer, len);
if (unlikely(block == NULL))
free (footer);
p_access->info.b_eof = true;
{
DIR *handle;
#ifdef HAVE_OPENAT
- int fd = vlc_openat (dirfd (current->handle), entry, O_RDONLY);
+ int fd = vlc_openat (dirfd (current->handle), entry,
+ O_RDONLY | O_DIRECTORY);
if (fd == -1)
+ {
+ if (errno == ENOTDIR)
+ goto notdir;
goto skip; /* File cannot be opened... forget it */
+ }
struct stat st;
- if (fstat (fd, &st))
- {
- close (fd);
- goto skip; /* cannot stat?! */
- }
- if (!S_ISDIR (st.st_mode))
- {
- close (fd);
- goto notdir;
- }
- if (p_sys->mode == MODE_NONE
+ if (fstat (fd, &st)
+ || p_sys->mode == MODE_NONE
|| has_inode_loop (current, st.st_dev, st.st_ino)
|| (handle = fdopendir (fd)) == NULL)
{
p_sys->xspf_ext = NULL;
free (old_xspf_ext);
- block_t *block = block_heap_Alloc (entry, entry, len);
+ block_t *block = block_heap_Alloc (entry, len);
if (unlikely(block == NULL))
{
free (entry);