]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/powe.c
Simple POSIX I/O emulation layer to work around Windows's defective
[empserver] / src / lib / commands / powe.c
index b05be45eb84c54d9a828ea5c0ccd58371476f48a..a66065f323b79bfc3edea40e50a79895b9d41833 100644 (file)
  */
 
 #include <config.h>
-
+#include <unistd.h>
 #include <math.h>
-#ifdef _WIN32
-#include <io.h>
-#endif
 
 #include "commands.h"
 #include "item.h"
@@ -317,14 +314,13 @@ gen_power(struct powstr *powbuf, int save)
        return;
     for (i = 0; i < MAXNOC; i++)
        putpower(i, &powbuf[i]);
-#ifdef _WIN32
     /*
-     * At least some versions of Windows fail to update mtime on
-     * write().  Bad, because `power' displays that time.  Attempt to
-     * force an update.
+     * At least some versions of Windows fail to update st_mtime on
+     * write(), the st_mtime is not until the file is written to the
+     * disk.  Bad, because `power' displays that time.
+     * Force a sync to ensure the st_time is correct.
      */
-    _commit(empfile[EF_POWER].fd);
-#endif
+    fsync(empfile[EF_POWER].fd);
 }
 
 static int