Skip to content

Commit d242360

Browse files
kkebokateinoigakukun
authored andcommitted
WASI: Implement fd_sync for Windows
1 parent 25547c6 commit d242360

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sources/SystemExtras/FileOperations.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,11 @@ extension FileDescriptor {
583583

584584
internal func _sync() -> Result<Void, Errno> {
585585
#if os(Windows)
586-
// TODO: Implement by `FlushFileBuffers`?
587-
return .failure(Errno(rawValue: ERROR_NOT_SUPPORTED))
586+
let handle = HANDLE(bitPattern: _get_osfhandle(self.rawValue))
587+
return nothingOrErrno(retryOnInterrupt: false) {
588+
let ok = FlushFileBuffers(handle)
589+
return ok ? 0 : -1
590+
}
588591
#else
589592
nothingOrErrno(retryOnInterrupt: false) {
590593
#if SYSTEM_PACKAGE_DARWIN

0 commit comments

Comments
 (0)