aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-13 04:21:24 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-13 04:21:24 +0000
commitbaa9ff77415a35317137262bb5865639c0f38429 (patch)
treef412139f2d6d04f8e4e5530b1f8ed650c4cb65f7
parent9e9ffbc4044d03600fa2f0ed1b288e8d711a1e0f (diff)
win32: minor optimization of file move.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1634 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog9
-rw-r--r--ChangeLog.ja10
-rw-r--r--libsylph/utils.c23
3 files changed, 32 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 313120d8..68355a70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-04-13
+
+ * libsylph/utils.c: file_exist(): use g_file_test() if allow_fifo is
+ FALSE (optimization in win32).
+ rename_force(): win32: don't use workaround in recent version of GLib
+ since its g_rename() now atomically overwrites the destination file.
+ move_file(): use is_file_entry_exist() instead of is_file_exist() in
+ non-overwrite mode.
+
2007-04-12
* version 2.4.0beta8
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 54ead643..931997e3 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,13 @@
+2007-04-13
+
+ * libsylph/utils.c: file_exist(): allow_fifo が FALSE の場合は
+ g_file_test() を使用(win32 の最適化)。
+ rename_force(): win32: 最近のバージョンの GLib では g_rename() は
+ アトミックに移動先ファイルを上書きするため、 workaround を行わない
+ ようにした。
+ move_file(): 非上書きモードでは is_file_exist() ではなく
+ is_file_entry_exist() を使用するようにした。
+
2007-04-12
* version 2.4.0beta8
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;
}