From baa9ff77415a35317137262bb5865639c0f38429 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 13 Apr 2007 04:21:24 +0000 Subject: win32: minor optimization of file move. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1634 ee746299-78ed-0310-b773-934348b2243d --- libsylph/utils.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'libsylph') 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; } -- cgit v1.2.3