fs

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: Apache-2.0 Imports: 11 Imported by: 7

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
)

Functions

func Exists

func Exists(file string) bool

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 Inode added in v1.5.0

func Inode(file string) (uint64, error)

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.

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
	// syncs file to disk (1st half of Save)
	Sync() error
	// links synced file to correct place in filesystem (2nd half of Save)
	Finalize(string) 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 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) Finalize added in v1.5.0

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

Finalize writes a synced file to its destination.

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. You can also use Sync and Finalize instead of Save

func (*TempFile) Sync added in v1.5.0

func (o *TempFile) Sync() error

sync file to disk

Jump to

Keyboard shortcuts

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