[vlc-devel] commit: Use stat rather than fopen+fclose to check if file exists ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Aug 30 18:25:55 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Aug 30 19:28:12 2008 +0300| [475d7593f8128d80352d548d38628fa938b706de] | committer: Rémi Denis-Courmont 

Use stat rather than fopen+fclose to check if file exists

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

 src/video_output/vout_intf.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 56ea99a..ea647f1 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>                                                /* free() */
 #include <sys/types.h>                                          /* opendir() */
+#include <sys/stat.h>
 #include <dirent.h>                                             /* opendir() */
 #include <assert.h>
 
@@ -730,7 +731,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
         if( var_GetBool( p_vout, "snapshot-sequential" ) == true )
         {
             int i_num = var_GetInteger( p_vout, "snapshot-num" );
-            FILE *p_file;
+            struct stat st;
+
             do
             {
                 free( psz_filename );
@@ -743,7 +745,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
                     return VLC_EGENERIC;
                 }
             }
-            while( ( p_file = utf8_fopen( psz_filename, "r" ) ) && !fclose( p_file ) );
+            while( utf8_stat( psz_filename, &st ) == 0 );
+
             var_SetInteger( p_vout, "snapshot-num", i_num );
         }
         else




More information about the vlc-devel mailing list