Documentation ¶
Index ¶
- func CreateAndSyncFile(filePath string, content []byte, perm os.FileMode) error
- func CreateAndSyncFileAtomically(dir, tmpFile, finalFile string, content []byte, perm os.FileMode) error
- func CreateDirIfMissing(dirPath string) (bool, error)
- func DirEmpty(dirPath string) (bool, error)
- func DirExists(path string) (bool, error)
- func FileExists(path string) (bool, int64, error)
- func ListSubdirs(dirPath string) ([]string, error)
- func RemoveContents(dir string) error
- func SyncDir(dirPath string) error
- func SyncParentDir(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAndSyncFile ¶
CreateAndSyncFile creates a file, writes the content and syncs the file
func CreateAndSyncFileAtomically ¶
func CreateAndSyncFileAtomically(dir, tmpFile, finalFile string, content []byte, perm os.FileMode) error
CreateAndSyncFileAtomically writes the content to the tmpFile, fsyncs the tmpFile, renames the tmpFile to the finalFile. In other words, in the event of a crash, either the final file will not be visible or it will have the full contents. The tmpFile should not be existing. The finalFile, if exists, will be overwritten (default rename behavior)
func CreateDirIfMissing ¶
CreateDirIfMissing makes sure that the dir exists and returns whether the dir is empty
func FileExists ¶
FileExists checks whether the given file exists. If the file exists, this method also returns the size of the file.
func ListSubdirs ¶
ListSubdirs returns the subdirectories
func RemoveContents ¶
RemoveContents removes all the files and subdirs under the specified directory. It returns nil if the specified directory does not exist.
func SyncParentDir ¶
SyncParentDir fsyncs the parent dir of the given path
Types ¶
This section is empty.