Documentation ¶
Index ¶
- Variables
- func Exists(file string) bool
- func GetFileMTime(filePath string) (int64, error)
- func Getxattr(fileNameOrFd interface{}, attr string, value []byte) (int, error)
- func IsFileNotExist(path string) bool
- func IsMount(dir string) (bool, error)
- func IsNotDir(err error) bool
- func LockPath(directory string, timeout time.Duration) (*os.File, error)
- func ReadDirNames(path string) ([]string, error)
- func Setxattr(fileNameOrFd interface{}, attr string, value []byte) (int, error)
- func TempDir(driveRoot, device string, policy int) string
- type AtomicFileWriter
- type MountMonitor
- type TempFile
Constants ¶
This section is empty.
Variables ¶
View Source
var ( AT_FDCWD = C.AT_FDCWD AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW O_TMPFILE = C.__O_TMPFILE | syscall.O_DIRECTORY FileMaxUnsynedBytes = 4 * 1024 * 1024 )
Functions ¶
func GetFileMTime ¶
func Getxattr ¶
Getxattr gets xattrs from a file, given a filename(string) or file descriptor(uintptr), an attribute name, and value buffer to store it to.
func IsFileNotExist ¶
func ReadDirNames ¶
Types ¶
type AtomicFileWriter ¶
type AtomicFileWriter interface { // Write writes the data to the underlying file. Write([]byte) (int, error) // Fd returns the file's underlying file descriptor. Fd() uintptr // Save atomically writes the file to its destination. Save(string) error // Abandon removes any resources associated with this file. Abandon() error // Preallocate pre-allocates space on disk, // given the expected file size and disk reserve size. Preallocate(int64, int64) error }
AtomicFileWriter saves a new file atomically.
func NewAtomicFileWriter ¶
func NewAtomicFileWriter( tempDir string, dstDir string) (AtomicFileWriter, error)
NewAtomicFileWriter returns an AtomicFileWriter, which handles atomically writing files.
type MountMonitor ¶
type MountMonitor struct {
// contains filtered or unexported fields
}
func NewMountMonitor ¶
func NewMountMonitor() *MountMonitor
func (*MountMonitor) RegisterCallback ¶
func (m *MountMonitor) RegisterCallback(name string, callback func())
func (*MountMonitor) Start ¶
func (m *MountMonitor) Start()
func (*MountMonitor) Stop ¶
func (m *MountMonitor) Stop()
func (*MountMonitor) UnregisterCallback ¶
func (m *MountMonitor) UnregisterCallback(name string)
type TempFile ¶
TempFile implements an atomic file writer using linux's O_TMPFILE/linkat mechanism if available. otherwise by writing to a temp directory and renaming.
func (*TempFile) Abandon ¶
Abandon removes any resources associated with this file, if it hasn't already been saved.
func (*TempFile) Preallocate ¶
Preallocate pre-allocates space for the file.
Click to show internal directories.
Click to hide internal directories.