io/FileOutputStream: add method Sync()
This commit is contained in:
@@ -138,6 +138,15 @@ FileOutputStream::Write(const void *data, size_t size)
|
||||
GetPath().c_str());
|
||||
}
|
||||
|
||||
void
|
||||
FileOutputStream::Sync()
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
if (!FlushFileBuffers(handle))
|
||||
throw FormatLastError("Failed to sync %s", GetPath().c_str());
|
||||
}
|
||||
|
||||
void
|
||||
FileOutputStream::Commit()
|
||||
{
|
||||
@@ -240,6 +249,15 @@ FileOutputStream::Write(const void *data, size_t size)
|
||||
GetPath().c_str());
|
||||
}
|
||||
|
||||
void
|
||||
FileOutputStream::Sync()
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
if (fdatasync(fd.Get()) < 0)
|
||||
throw FormatErrno("Failed to sync %s", GetPath().c_str());
|
||||
}
|
||||
|
||||
void
|
||||
FileOutputStream::Commit()
|
||||
{
|
||||
|
Reference in New Issue
Block a user