[vlc-devel] commit: Don't use stat() before opendir() ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue May 20 18:02:23 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Tue May 20 18:59:28 2008 +0300| [7b98e85b48a69ad0519dee858fbbebd461c84537]

Don't use stat() before opendir()

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

 modules/control/http/mvar.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/modules/control/http/mvar.c b/modules/control/http/mvar.c
index 15d6770..143d386 100644
--- a/modules/control/http/mvar.c
+++ b/modules/control/http/mvar.c
@@ -503,20 +503,12 @@ mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
                              char *psz_dir )
 {
     mvar_t *s = mvar_New( name, "set" );
-#ifdef HAVE_SYS_STAT_H
-    struct stat   stat_info;
-#endif
     char        **ppsz_dir_content;
     int           i_dir_content, i;
     psz_dir = RealPath( p_intf, psz_dir );
 
-#ifdef HAVE_SYS_STAT_H
-    if( (utf8_stat( psz_dir, &stat_info ) == -1 )
-     || !S_ISDIR( stat_info.st_mode )
-#   if defined( WIN32 )
-          && psz_dir[0] != '\0' && (psz_dir[0] != '\\' || psz_dir[1] != '\0')
-#   endif
-      )
+#if defined( WIN32 )
+    if( psz_dir[0] != '\0' && (psz_dir[0] != '\\' || psz_dir[1] != '\0') )
     {
         free( psz_dir );
         return s;
@@ -527,13 +519,17 @@ mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
     if( ( i_dir_content = utf8_scandir( psz_dir, &ppsz_dir_content, Filter,
                                         InsensitiveAlphasort ) ) == -1 )
     {
-        msg_Warn( p_intf, "error while scanning dir %s (%m)", psz_dir );
+        if( errno != ENOENT && errno != ENOTDIR )
+            msg_Warn( p_intf, "error while scanning dir %s (%m)", psz_dir );
         free( psz_dir );
         return s;
     }
 
     for( i = 0; i < i_dir_content; i++ )
     {
+#ifdef HAVE_SYS_STAT_H
+        struct stat stat_info;
+#endif
         char *psz_name = ppsz_dir_content[i], *psz_ext, *psz_dummy;
         char psz_tmp[strlen( psz_dir ) + 1 + strlen( psz_name ) + 1];
         mvar_t *f;




More information about the vlc-devel mailing list