Skip to content

Commit 8fc3bac

Browse files
committed
Fix fsync/fdatasync for windows
1 parent fae7b81 commit 8fc3bac

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/node_file.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ static Handle<Value> Fdatasync(const Arguments& args) {
437437
} else {
438438
#if HAVE_FDATASYNC
439439
int ret = fdatasync(fd);
440+
#elif defined(__MINGW32__)
441+
int ret = FlushFileBuffers((HANDLE)_get_osfhandle(fd)) ? 0 : -1;
440442
#else
441443
int ret = fsync(fd);
442444
#endif
@@ -457,7 +459,11 @@ static Handle<Value> Fsync(const Arguments& args) {
457459
if (args[1]->IsFunction()) {
458460
ASYNC_CALL(fsync, args[1], fd)
459461
} else {
462+
#ifdef __MINGW32__
463+
int ret = FlushFileBuffers((HANDLE)_get_osfhandle(fd)) ? 0 : -1;
464+
#else
460465
int ret = fsync(fd);
466+
#endif
461467
if (ret != 0) return ThrowException(ErrnoException(errno));
462468
return Undefined();
463469
}

0 commit comments

Comments
 (0)