os: add os.(*File).Sync

Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
This commit is contained in:
Achille Roussel
2023-05-01 11:07:29 -07:00
committed by Ron Evans
parent 4fa6a132e2
commit ccfe92a58c
8 changed files with 27 additions and 15 deletions
+12
View File
@@ -247,6 +247,18 @@ func (f *File) Fd() uintptr {
return ^uintptr(0)
}
// Sync commits the current contents of the file to stable storage.
// Typically, this means flushing the file system's in-memory copy of recently
// written data to disk.
func (f *File) Sync() (err error) {
if f.handle == nil {
err = ErrClosed
} else {
err = f.handle.Sync()
}
return
}
// Truncate is a stub, not yet implemented
func (f *File) Truncate(size int64) (err error) {
if f.handle == nil {