fileutil

package
v2.3.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fileutil implements utility functions related to files and paths.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLocked = errors.New("file already locked")
)

Functions

func Exist added in v2.3.0

func Exist(name string) bool

func IsDirWriteable

func IsDirWriteable(dir string) error

IsDirWriteable checks if dir is writable by writing and removing a file to dir. It returns nil if dir is writable.

func Preallocate added in v2.2.0

func Preallocate(f *os.File, sizeInBytes int) error

Preallocate tries to allocate the space for given file. This operation is only supported on linux by a few filesystems (btrfs, ext4, etc.). If the operation is unsupported, no error will be returned. Otherwise, the error encountered will be returned.

func PurgeFile

func PurgeFile(dirname string, suffix string, max uint, interval time.Duration, stop <-chan struct{}) <-chan error

func ReadDir

func ReadDir(dirpath string) ([]string, error)

ReadDir returns the filenames in the given directory in sorted order.

func TouchDirAll added in v2.2.3

func TouchDirAll(dir string) error

TouchDirAll is similar to os.MkdirAll. It creates directories with 0700 permission if any directory does not exists. TouchDirAll also ensures the given directory is writable.

Types

type Lock

type Lock interface {
	Name() string
	TryLock() error
	Lock() error
	Unlock() error
	Destroy() error
}

func NewLock

func NewLock(file string) (Lock, error)

Jump to

Keyboard shortcuts

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