From 2b06ada7c106293ecb0437e4c6e1a8809279d688 Mon Sep 17 00:00:00 2001 From: calvinwilliams Date: Fri, 1 Feb 2019 16:09:49 +0800 Subject: [PATCH] use stat() replace readdir --- src/util/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/file.c b/src/util/file.c index 696be26..6bb7bc3 100644 --- a/src/util/file.c +++ b/src/util/file.c @@ -227,12 +227,12 @@ int IsDirectoryNewThan( char *path , time_t mtime ) if( Snprintf( sub_path , sizeof(sub_path) , "%s/%s" , path , dirent->d_name ) == NULL ) return -2; - if( dirent->d_type == DT_DIR ) + memset( & dir_stat , 0x00 , sizeof(struct stat) ); + nret = stat( sub_path , & dir_stat ) ; + if( nret == -1 ) + return -3; + if( S_ISDIR(dir_stat.st_mode) ) { - memset( & dir_stat , 0x00 , sizeof(struct stat) ); - nret = stat( sub_path , & dir_stat ) ; - if( nret == -1 ) - return -3; if( dir_stat.st_mtime > mtime ) return 1;