diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-03-17 09:45:30 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2009-03-17 09:45:30 +0000 |
commit | de2c3c4a63814b0852b17a822274453afda67188 (patch) | |
tree | 831cd0db73f7379bdddff99934dde541cf9a22dc | |
parent | d0240722220985b4ca879c6caa1ca927d5309588 (diff) |
win32: use _commit().
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2123 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | libsylph/prefs.c | 29 |
2 files changed, 23 insertions, 11 deletions
@@ -1,5 +1,10 @@ 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. 2008-03-17 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 <unistd.h> #include <errno.h> +#ifdef G_OS_WIN32 +# include <windows.h> +# include <io.h> +#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) { |