diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-06-24 09:11:54 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-06-24 09:11:54 +0000 |
commit | ec268f92052fc3469e6a0d582da4151c3a5f1163 (patch) | |
tree | c68ba003133dc1c92d55d5f8fb3e7d2e9112369f /src/utils.c | |
parent | 8aa69d94d7affada32b509d7171697b7021ba009 (diff) |
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
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 29 |
1 files changed, 4 insertions, 25 deletions
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) |