fs

package
v0.0.0-...-a0bb070 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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 Exists

func Exists(file string) bool

func GetFileMTime

func GetFileMTime(filePath string) (int64, error)

func Getxattr

func Getxattr(fileNameOrFd interface{}, attr string, value []byte) (int, error)

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 IsFileNotExist(path string) bool

func IsMount

func IsMount(dir string) (bool, error)

func IsNotDir

func IsNotDir(err error) bool

func LockPath

func LockPath(directory string, timeout time.Duration) (*os.File, error)

LockPath locks a directory with a timeout.

func ReadDirNames

func ReadDirNames(path string) ([]string, error)

func Setxattr

func Setxattr(fileNameOrFd interface{}, attr string, value []byte) (int, error)

Setxattr sets xattrs for a file, given a file descriptor, attribute name, and value buffer.

func TempDir

func TempDir(driveRoot, device string, policy int) string

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

type TempFile struct {
	*os.File
	// contains filtered or unexported fields
}

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

func (o *TempFile) Abandon() error

Abandon removes any resources associated with this file, if it hasn't already been saved.

func (*TempFile) Preallocate

func (o *TempFile) Preallocate(size int64, reserve int64) error

Preallocate pre-allocates space for the file.

func (*TempFile) Save

func (o *TempFile) Save(dst string) error

Save atomically writes the file to its destination.

func (*TempFile) Write

func (o *TempFile) Write(b []byte) (int, error)

Write temp file with sync mode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL