Documentation ¶
Index ¶
- Constants
- func GetFilepath(baseDir, path string) string
- func IsDirOrSymlink(de os.DirEntry) bool
- func IsEmptyDir(path string) bool
- func IsPathExist(path string) bool
- func IsScheduledForRemoval(filename string) bool
- func IsTemporaryFileName(fn string) bool
- func MustClose(f *os.File)
- func MustCopyDirectory(srcPath, dstPath string)
- func MustCopyFile(srcPath, dstPath string)
- func MustCreateFlockFile(dir string) *os.File
- func MustFileSize(path string) uint64
- func MustGetFreeSpace(path string) uint64
- func MustHardLinkFiles(srcDir, dstDir string)
- func MustMkdirFailIfExist(path string)
- func MustMkdirIfNotExist(path string)
- func MustReadDir(dir string) []os.DirEntry
- func MustRemoveAll(path string)
- func MustRemoveDirAtomic(dir string)
- func MustRemoveTemporaryDirs(dir string)
- func MustStopDirRemover()
- func MustSymlinkRelative(srcPath, dstPath string)
- func MustSyncPath(path string)
- func ReadFileOrHTTP(path string) ([]byte, error)
- func RemoveDirContents(dir string)
Constants ¶
const FlockFilename = "flock.lock"
FlockFilename is the filename for the file created by MustCreateFlockFile().
Variables ¶
This section is empty.
Functions ¶
func GetFilepath ¶
GetFilepath returns full path to file for the given baseDir and path.
func IsDirOrSymlink ¶
IsDirOrSymlink returns true if de is directory or symlink.
func IsEmptyDir ¶
IsEmptyDir returns true if path points to empty directory.
func IsPathExist ¶
IsPathExist returns whether the given path exists.
func IsScheduledForRemoval ¶
IsScheduledForRemoval returns true if the filename contains .must-remove. substring
func IsTemporaryFileName ¶
IsTemporaryFileName returns true if fn matches temporary file name pattern from MustWriteAtomic.
func MustCopyDirectory ¶
func MustCopyDirectory(srcPath, dstPath string)
MustCopyDirectory copies all the files in srcPath to dstPath.
func MustCopyFile ¶
func MustCopyFile(srcPath, dstPath string)
MustCopyFile copies the file from srcPath to dstPath.
func MustCreateFlockFile ¶
MustCreateFlockFile creates FlockFilename file in the directory dir and returns the handler to the file.
func MustFileSize ¶
MustFileSize returns file size for the given path.
func MustGetFreeSpace ¶
MustGetFreeSpace returns free space for the given directory path.
func MustHardLinkFiles ¶
func MustHardLinkFiles(srcDir, dstDir string)
MustHardLinkFiles makes hard links for all the files from srcDir in dstDir.
func MustMkdirFailIfExist ¶
func MustMkdirFailIfExist(path string)
MustMkdirFailIfExist creates the given path dir if it isn't exist.
If the directory at the given path already exists, then the function logs the error and exits.
func MustMkdirIfNotExist ¶
func MustMkdirIfNotExist(path string)
MustMkdirIfNotExist creates the given path dir if it isn't exist.
func MustReadDir ¶
MustReadDir reads directory entries at the given dir.
func MustRemoveAll ¶
func MustRemoveAll(path string)
MustRemoveAll removes path with all the contents.
It properly fsyncs the parent directory after path removal.
It properly handles NFS issue https://github.com/VictoriaMetrics/VictoriaMetrics/issues/61 .
func MustRemoveDirAtomic ¶
func MustRemoveDirAtomic(dir string)
MustRemoveDirAtomic removes the given dir atomically.
It uses the following algorithm:
- Atomically rename the "<dir>" to "<dir>.must-remove.<XYZ>", where <XYZ> is an unique number.
- Remove the "<dir>.must-remove.XYZ" in background.
If the process crashes after the step 1, then the directory must be removed on the next process start by calling MustRemoveTemporaryDirs on the parent directory.
func MustRemoveTemporaryDirs ¶
func MustRemoveTemporaryDirs(dir string)
MustRemoveTemporaryDirs removes all the subdirectories with ".must-remove.<XYZ>" suffix.
Such directories may be left on unclean shutdown during MustRemoveDirAtomic call.
func MustStopDirRemover ¶
func MustStopDirRemover()
MustStopDirRemover must be called in the end of graceful shutdown in order to wait for removing the remaining directories from removeDirConcurrencyCh.
It is expected that nobody calls MustRemoveAll when MustStopDirRemover is called.
func MustSymlinkRelative ¶
func MustSymlinkRelative(srcPath, dstPath string)
MustSymlinkRelative creates relative symlink for srcPath in dstPath.
func ReadFileOrHTTP ¶
ReadFileOrHTTP reads path either from local filesystem or from http if path starts with http or https.
func RemoveDirContents ¶
func RemoveDirContents(dir string)
RemoveDirContents removes all the contents of the given dir if it exists.
It doesn't remove the dir itself, so the dir may be mounted to a separate partition.
Types ¶
This section is empty.