[vlc-commits] directory: stat() fallback if *at() functions are missing

Rémi Denis-Courmont git at videolan.org
Thu Nov 5 20:35:11 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov  5 21:34:30 2015 +0200| [2b757516f903932473f30a5f7bc55a86dac41937] | committer: Rémi Denis-Courmont

directory: stat() fallback if *at() functions are missing

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2b757516f903932473f30a5f7bc55a86dac41937
---

 modules/access/directory.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index f0e5826..07614bc 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -119,13 +119,19 @@ input_item_t *DirRead(access_t *access)
 
     while ((entry = vlc_readdir(sys->dir)) != NULL)
     {
-        int type;
-#ifdef HAVE_OPENAT
         struct stat st;
+        int type;
 
+#ifdef HAVE_OPENAT
         if (fstatat(dirfd(sys->dir), entry, &st, 0))
             continue;
+#else
+        char path[PATH_MAX];
 
+        if (snprintf(path, PATH_MAX, "%s"DIR_SEP"%s", access->psz_filepath,
+                     entry) >= PATH_MAX || vlc_stat(path, &st))
+            continue;
+#endif
         switch (st.st_mode & S_IFMT)
         {
             case S_IFBLK:
@@ -154,9 +160,6 @@ input_item_t *DirRead(access_t *access)
             default:
                 continue; /* ignore */
         }
-#else
-        type = ITEM_TYPE_FILE;
-#endif
 
         /* Create an input item for the current entry */
         char *encoded= encode_URI_component(entry);



More information about the vlc-commits mailing list