From ec268f92052fc3469e6a0d582da4151c3a5f1163 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 24 Jun 2005 09:11:54 +0000 Subject: use g_file_test() instead of stat() in some functions. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@377 ee746299-78ed-0310-b773-934348b2243d --- src/utils.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 3d022d9e..3955a3ef 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1828,41 +1828,22 @@ gboolean file_exist(const gchar *file, gboolean allow_fifo) gboolean is_dir_exist(const gchar *dir) { - struct stat s; - if (dir == NULL) return FALSE; - if (stat(dir, &s) < 0) { - if (ENOENT != errno) FILE_OP_ERROR(dir, "stat"); - return FALSE; - } - - if (S_ISDIR(s.st_mode)) - return TRUE; - - return FALSE; + return g_file_test(dir, G_FILE_TEST_IS_DIR); } gboolean is_file_entry_exist(const gchar *file) { - struct stat s; - if (file == NULL) return FALSE; - if (stat(file, &s) < 0) { - if (ENOENT != errno) FILE_OP_ERROR(file, "stat"); - return FALSE; - } - - return TRUE; + return g_file_test(file, G_FILE_TEST_EXISTS); } gboolean dirent_is_regular_file(struct dirent *d) { - struct stat s; - #ifdef HAVE_DIRENT_D_TYPE if (d->d_type == DT_REG) return TRUE; @@ -1870,13 +1851,11 @@ gboolean dirent_is_regular_file(struct dirent *d) return FALSE; #endif - return (stat(d->d_name, &s) == 0 && S_ISREG(s.st_mode)); + return g_file_test(d->d_name, G_FILE_TEST_IS_REGULAR); } gboolean dirent_is_directory(struct dirent *d) { - struct stat s; - #ifdef HAVE_DIRENT_D_TYPE if (d->d_type == DT_DIR) return TRUE; @@ -1884,7 +1863,7 @@ gboolean dirent_is_directory(struct dirent *d) return FALSE; #endif - return (stat(d->d_name, &s) == 0 && S_ISDIR(s.st_mode)); + return g_file_test(d->d_name, G_FILE_TEST_IS_DIR); } gint change_dir(const gchar *dir) -- cgit v1.2.3