From de2c3c4a63814b0852b17a822274453afda67188 Mon Sep 17 00:00:00 2001 From: hiro Date: Tue, 17 Mar 2009 09:45:30 +0000 Subject: win32: use _commit(). git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2123 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 5 +++++ libsylph/prefs.c | 29 ++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index df91aa77..5ba39fba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-17 + + * libsylph/prefs.c: prefs_file_close(): win32: use _commit() as well + as fsync() on Unix. + 2008-03-17 * libsylph/prefs.c: prefs_file_close(): abort if fsync() fails. diff --git a/libsylph/prefs.c b/libsylph/prefs.c index 56a2eda6..12dd057c 100644 --- a/libsylph/prefs.c +++ b/libsylph/prefs.c @@ -1,6 +1,6 @@ /* * LibSylph -- E-Mail client library - * Copyright (C) 1999-2008 Hiroyuki Yamamoto + * Copyright (C) 1999-2009 Hiroyuki Yamamoto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,6 +29,11 @@ #include #include +#ifdef G_OS_WIN32 +# include +# include +#endif + #include "prefs.h" #include "codeconv.h" #include "utils.h" @@ -373,9 +378,6 @@ gint prefs_file_close(PrefFile *pfile) { PrefFilePrivate *priv = (PrefFilePrivate *)pfile; FILE *fp; -#if HAVE_FSYNC - gint fd; -#endif gchar *path; gchar *tmppath; gchar *bakpath = NULL; @@ -397,13 +399,18 @@ gint prefs_file_close(PrefFile *pfile) goto finish; } #if HAVE_FSYNC - if ((fd = fileno(fp)) >= 0) { - if (fsync(fd) < 0) { - FILE_OP_ERROR(tmppath, "fsync"); - fclose(fp); - ret = -1; - goto finish; - } + if (fsync(fileno(fp)) < 0) { + FILE_OP_ERROR(tmppath, "fsync"); + fclose(fp); + ret = -1; + goto finish; + } +#elif defined(G_OS_WIN32) + if (_commit(_fileno(fp)) < 0) { + FILE_OP_ERROR(tmppath, "_commit"); + fclose(fp); + ret = -1; + goto finish; } #endif if (fclose(fp) == EOF) { -- cgit v1.2.3