WIN32 compilation error fixes.
[silc.git] / lib / silcutil / silcfileutil.c
index 718cb6f1fb6f77dd5fe50e1dea684b49f28bc1b9..e824a2f12b886d51bc39c43dc573179b6a14d8b0 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2005 Pekka Riikonen
+  Copyright (C) 1997 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
 */
 /* $Id$ */
 
-#include "silcincludes.h"
+#include "silc.h"
 
 /* Opens a file indicated by the filename `filename' with flags indicated
    by the `flags'. */
@@ -82,9 +82,11 @@ int silc_file_writefile(const char *filename, const char *buffer,
     return -1;
   }
 
-  silc_file_close(fd);
+#ifdef SILC_UNIX
+  fsync(fd);
+#endif /* SILC_UNIX */
 
-  return 0;
+  return silc_file_close(fd);
 }
 
 /* Writes a buffer to the file.  If the file is created specific mode is
@@ -112,9 +114,11 @@ int silc_file_writefile_mode(const char *filename, const char *buffer,
     return -1;
   }
 
-  silc_file_close(fd);
+#ifdef SILC_UNIX
+  fsync(fd);
+#endif /* SILC_UNIX */
 
-  return 0;
+  return silc_file_close(fd);
 }
 
 /* Reads a file to a buffer. The allocated buffer is returned. Length of