diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-04-13 04:21:24 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-04-13 04:21:24 +0000 |
commit | baa9ff77415a35317137262bb5865639c0f38429 (patch) | |
tree | f412139f2d6d04f8e4e5530b1f8ed650c4cb65f7 /libsylph | |
parent | 9e9ffbc4044d03600fa2f0ed1b288e8d711a1e0f (diff) |
win32: minor optimization of file move.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1634 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/utils.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c index c5c3a9d8..b67b6867 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -2179,18 +2179,21 @@ off_t get_left_file_size(FILE *fp) gboolean file_exist(const gchar *file, gboolean allow_fifo) { - struct stat s; - if (file == NULL) return FALSE; - if (g_stat(file, &s) < 0) { - if (ENOENT != errno) FILE_OP_ERROR(file, "stat"); - return FALSE; - } + if (allow_fifo) { + struct stat s; - if (S_ISREG(s.st_mode) || (allow_fifo && S_ISFIFO(s.st_mode))) - return TRUE; + if (g_stat(file, &s) < 0) { + if (ENOENT != errno) FILE_OP_ERROR(file, "stat"); + return FALSE; + } + if (S_ISREG(s.st_mode) || S_ISFIFO(s.st_mode)) + return TRUE; + } else { + return g_file_test(file, G_FILE_TEST_IS_REGULAR); + } return FALSE; } @@ -2552,7 +2555,7 @@ leave: gint rename_force(const gchar *oldpath, const gchar *newpath) { -#ifndef G_OS_UNIX +#if !defined(G_OS_UNIX) && !GLIB_CHECK_VERSION(2, 9, 1) if (!is_file_entry_exist(oldpath)) { errno = ENOENT; return -1; @@ -2682,7 +2685,7 @@ gint copy_dir(const gchar *src, const gchar *dest) gint move_file(const gchar *src, const gchar *dest, gboolean overwrite) { - if (overwrite == FALSE && is_file_exist(dest)) { + if (overwrite == FALSE && is_file_entry_exist(dest)) { g_warning("move_file(): file %s already exists.", dest); return -1; } |