[gconf/gdbus] Implement replacement fsync() on windows, where it is not present
- From: Fridrich Strba <strba src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gconf/gdbus] Implement replacement fsync() on windows, where it is not present
- Date: Fri, 28 May 2010 08:52:12 +0000 (UTC)
commit a1e41a1826de470f2eecfa2e7be7cb9cf0e2847c
Author: Fridrich Å trba <fridrich strba bluewin ch>
Date: Fri May 28 09:18:54 2010 +0200
Implement replacement fsync() on windows, where it is not present
backends/markup-tree.c | 37 +++++++++++++++++++++++++++++++++++++
gconf/gconfd.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/backends/markup-tree.c b/backends/markup-tree.c
index c08d6c7..4857cae 100644
--- a/backends/markup-tree.c
+++ b/backends/markup-tree.c
@@ -34,6 +34,43 @@
#include <stdio.h>
#include <time.h>
+#ifdef G_OS_WIN32
+#include <io.h>
+#include <conio.h>
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+
+static int
+fsync (int fd)
+{
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ DWORD err;
+
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ if (!FlushFileBuffers (h))
+ {
+ err = GetLastError ();
+ switch (err)
+ {
+ case ERROR_INVALID_HANDLE:
+ errno = EINVAL;
+ break;
+
+ default:
+ errno = EIO;
+ }
+ return -1;
+ }
+
+ return 0;
+}
+#endif
+
typedef struct
{
char *locale;
diff --git a/gconf/gconfd.c b/gconf/gconfd.c
index f5b7f9d..5d49fad 100644
--- a/gconf/gconfd.c
+++ b/gconf/gconfd.c
@@ -62,6 +62,36 @@
#include <conio.h>
#define _WIN32_WINNT 0x0500
#include <windows.h>
+
+static int
+fsync (int fd)
+{
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ DWORD err;
+
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ if (!FlushFileBuffers (h))
+ {
+ err = GetLastError ();
+ switch (err)
+ {
+ case ERROR_INVALID_HANDLE:
+ errno = EINVAL;
+ break;
+
+ default:
+ errno = EIO;
+ }
+ return -1;
+ }
+
+ return 0;
+}
#endif
/* This makes hash table safer when debugging */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]