io/FileOutputStream: use fsync() if fdatasync() is unavailable
Fixes the macOS build which apparently doesn't implement the POSIX function fdatasync().
This commit is contained in:
parent
bc7fdba36d
commit
150e8f78bf
@ -252,7 +252,12 @@ FileOutputStream::Sync()
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
if (fdatasync(fd.Get()) < 0)
|
||||
#ifdef __linux__
|
||||
const bool success = fdatasync(fd.Get()) == 0;
|
||||
#else
|
||||
const bool success = fsync(fd.Get()) == 0;
|
||||
#endif
|
||||
if (!success)
|
||||
throw FormatErrno("Failed to sync %s", GetPath().c_str());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user