package fileutil
import "github.com/coreos/etcd/pkg/fileutil"
Package fileutil implements utility functions related to files and paths.
Index ¶
- Constants
- Variables
- func CreateDirAll(dir string) error
- func Exist(name string) bool
- func Fdatasync(f *os.File) error
- func Fsync(f *os.File) error
- func IsDirWriteable(dir string) error
- func OpenDir(path string) (*os.File, error)
- func Preallocate(f *os.File, sizeInBytes int64, extendFile bool) error
- func PurgeFile(dirname string, suffix string, max uint, interval time.Duration, stop <-chan struct{}) <-chan error
- func ReadDir(dirpath string) ([]string, error)
- func TouchDirAll(dir string) error
- func ZeroToEnd(f *os.File) error
- type LockedFile
Constants ¶
const ( // PrivateFileMode grants owner to read/write a file. PrivateFileMode = 0600 // PrivateDirMode grants owner to make/remove files inside the directory. PrivateDirMode = 0700 )
Variables ¶
Functions ¶
func CreateDirAll ¶
CreateDirAll is similar to TouchDirAll but returns error if the deepest directory was not empty.
func Exist ¶
func Fdatasync ¶
Fdatasync is a wrapper around file.Sync(). Special handling is needed on linux platform.
func Fsync ¶
Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform.
func IsDirWriteable ¶
IsDirWriteable checks if dir is writable by writing and removing a file to dir. It returns nil if dir is writable.
func OpenDir ¶
OpenDir opens a directory for syncing.
func Preallocate ¶
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 ¶
ReadDir returns the filenames in the given directory in sorted order.
func TouchDirAll ¶
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.
func ZeroToEnd ¶
ZeroToEnd zeros a file starting from SEEK_CUR to its SEEK_END. May temporarily shorten the length of the file.
Types ¶
type LockedFile ¶
func LockFile ¶
func TryLockFile ¶
Source Files ¶
dir_unix.go fileutil.go lock.go lock_flock.go lock_unix.go preallocate.go preallocate_unsupported.go purge.go sync.go
- Version
- v3.2.4+incompatible
- Published
- Jul 19, 2017
- Platform
- js/wasm
- Imports
- 11 packages
- Last checked
- 1 hour ago –
Tools for package owners.