aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-06-24 09:11:54 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-06-24 09:11:54 +0000
commitec268f92052fc3469e6a0d582da4151c3a5f1163 (patch)
treec68ba003133dc1c92d55d5f8fb3e7d2e9112369f
parent8aa69d94d7affada32b509d7171697b7021ba009 (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
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.ja8
-rw-r--r--src/utils.c29
3 files changed, 20 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 17d68a56..f9c9b0ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2005-06-24
+ * src/utils.c:
+ is_dir_exist()
+ is_file_entry_exist()
+ dirent_is_regular_file()
+ dirent_is_directory(): use g_file_test() instead of stat().
+
+2005-06-24
+
* src/ssl.c: verify SSL certificate (thanks to Kazuhiro NISHIYAMA).
2005-06-24
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 26e8babf..ef7b5195 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,13 @@
2005-06-24
+ * src/utils.c:
+ is_dir_exist()
+ is_file_entry_exist()
+ dirent_is_regular_file()
+ dirent_is_directory(): stat() でなく g_file_test() を使用。
+
+2005-06-24
+
* src/ssl.c: SSL 証明書を検証(西山さん thanks)。
2005-06-24
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)