[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
Thu Sep 4 22:38:26 CEST 2008


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

Use stat rather than fopen+fclose to check if file exists
(cherry picked from commit 475d7593f8128d80352d548d38628fa938b706de)

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

 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 417e5ce..aabe7a2 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>
 
@@ -659,7 +660,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
             {
                 if( asprintf( &psz_filename, "%s" DIR_SEP "%s%05d.%s",
@@ -671,7 +673,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