Commit 475d7593 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

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

parent be0af925
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* free() */ #include <stdlib.h> /* free() */
#include <sys/types.h> /* opendir() */ #include <sys/types.h> /* opendir() */
#include <sys/stat.h>
#include <dirent.h> /* opendir() */ #include <dirent.h> /* opendir() */
#include <assert.h> #include <assert.h>
...@@ -730,7 +731,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -730,7 +731,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
if( var_GetBool( p_vout, "snapshot-sequential" ) == true ) if( var_GetBool( p_vout, "snapshot-sequential" ) == true )
{ {
int i_num = var_GetInteger( p_vout, "snapshot-num" ); int i_num = var_GetInteger( p_vout, "snapshot-num" );
FILE *p_file; struct stat st;
do do
{ {
free( psz_filename ); free( psz_filename );
...@@ -743,7 +745,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -743,7 +745,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
return VLC_EGENERIC; 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 ); var_SetInteger( p_vout, "snapshot-num", i_num );
} }
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment