[vlc-devel] commit: LUA: fopen/fclose -> stat ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sat Feb 6 14:58:31 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 6 15:44:06 2010 +0200| [f45d4512a5b9977646cbd2c8623b13075a29c3c1] | committer: Rémi Denis-Courmont
LUA: fopen/fclose -> stat
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f45d4512a5b9977646cbd2c8623b13075a29c3c1
---
modules/misc/lua/intf.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/modules/misc/lua/intf.c b/modules/misc/lua/intf.c
index 7a80ef4..70e590a 100644
--- a/modules/misc/lua/intf.c
+++ b/modules/misc/lua/intf.c
@@ -39,6 +39,8 @@
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include <vlc_aout.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <lua.h> /* Low level lua C API */
#include <lauxlib.h> /* Higher level C API */
@@ -65,17 +67,18 @@ static char *FindFile( vlc_object_t *p_this, const char *psz_name )
for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
{
char *psz_filename;
- FILE *fp;
+ struct stat st;
+
if( asprintf( &psz_filename, "%s"DIR_SEP"%s.lua", *ppsz_dir,
psz_name ) < 0 )
{
vlclua_dir_list_free( ppsz_dir_list );
return NULL;
}
- fp = fopen( psz_filename, "r" );
- if( fp )
+
+ if( utf8_stat( psz_filename, &st ) == 0
+ && S_ISREG( st.st_mode ) )
{
- fclose( fp );
vlclua_dir_list_free( ppsz_dir_list );
return psz_filename;
}
More information about the vlc-devel
mailing list