diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2010-05-28 09:18:54 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2010-05-28 09:18:54 +0200 |
commit | 2804406f1c3ac4abd773a251a88da26a89b4fbb5 (patch) | |
tree | dccb8e85fd72ecacf1342ebc51fe9dcfb7b5ca5b | |
parent | 2a7c4d53cf6f6fd6a8cad0052c7d8cc7468d3a73 (diff) | |
download | gconf-2804406f1c3ac4abd773a251a88da26a89b4fbb5.tar.gz |
Implement replacement fsync() on windows, where it is not present
-rw-r--r-- | backends/markup-tree.c | 37 | ||||
-rw-r--r-- | gconf/gconfd.c | 30 |
2 files changed, 67 insertions, 0 deletions
diff --git a/backends/markup-tree.c b/backends/markup-tree.c index c08d6c79..4857caec 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 66c18ffc..2827635d 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 */ |