github.com/coocood/badger@v1.5.1-0.20200528065104-c02ac3616d04/fileutil/sync_darwin.go (about)

     1  // +build darwin
     2  
     3  package fileutil
     4  
     5  import (
     6  	"os"
     7  	"syscall"
     8  )
     9  
    10  // Fsync on darwin platform flushes the data on to the physical drive but the drive
    11  // may not write it to the persistent media for quite sometime and it may be
    12  // written in out-of-order sequence.
    13  func Fsync(f *os.File) error {
    14  	err := syscall.Fsync(int(f.Fd()))
    15  	return err
    16  }
    17  
    18  // Fdatasync is the same as Fsync on darwin platform.
    19  func Fdatasync(f *os.File) error {
    20  	return Fsync(f)
    21  }