fs

package
v1.61.1-cluster Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0 Imports: 16 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDirectory added in v1.54.0

func CopyDirectory(srcPath, dstPath string) error

CopyDirectory copies all the files in srcPath to dstPath.

func CreateFlockFile added in v1.25.0

func CreateFlockFile(dir string) (*os.File, error)

CreateFlockFile creates flock.lock file in the directory dir and returns the handler to the file.

func HardLinkFiles

func HardLinkFiles(srcDir, dstDir string) error

HardLinkFiles makes hard links for all the files from srcDir in dstDir.

func IsDirOrSymlink(fi os.FileInfo) bool

IsDirOrSymlink returns true if fi is directory or symlink.

func IsEmptyDir added in v1.59.0

func IsEmptyDir(path string) bool

IsEmptyDir returns true if path points to empty directory.

func IsPathExist

func IsPathExist(path string) bool

IsPathExist returns whether the given path exists.

func IsTemporaryFileName added in v1.25.0

func IsTemporaryFileName(fn string) bool

IsTemporaryFileName returns true if fn matches temporary file name pattern from WriteFileAtomically.

func MkdirAllFailIfExist

func MkdirAllFailIfExist(path string) error

MkdirAllFailIfExist creates the given path dir if it isn't exist.

Returns error if path already exists.

func MkdirAllIfNotExist

func MkdirAllIfNotExist(path string) error

MkdirAllIfNotExist creates the given path dir if it isn't exist.

func MustClose

func MustClose(f *os.File)

MustClose must close the given file f.

func MustFileSize added in v1.21.2

func MustFileSize(path string) uint64

MustFileSize returns file size for the given path.

func MustGetFreeSpace added in v1.27.0

func MustGetFreeSpace(path string) uint64

MustGetFreeSpace returns free space for the given directory path.

func MustRemoveAll added in v1.19.0

func MustRemoveAll(path string)

MustRemoveAll removes path with all the contents.

It properly fsyncs the parent directory after path removal.

It properly handles NFS issue https://github.com/VictoriaMetrics/VictoriaMetrics/issues/61 .

func MustRemoveAllWithDoneCallback added in v1.30.3

func MustRemoveAllWithDoneCallback(path string, done func())

MustRemoveAllWithDoneCallback removes path with all the contents.

It properly fsyncs the parent directory after path removal.

done is called after the path is successfully removed.

done may be called after the function returns for NFS path. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/61.

func MustStopDirRemover added in v1.27.2

func MustStopDirRemover()

MustStopDirRemover must be called in the end of graceful shutdown in order to wait for removing the remaining directories from removeDirConcurrencyCh.

It is expected that nobody calls MustRemoveAll when MustStopDirRemover is called.

func MustSyncPath added in v1.19.2

func MustSyncPath(path string)

MustSyncPath syncs contents of the given path.

func MustWriteData

func MustWriteData(w io.Writer, data []byte)

MustWriteData writes data to w.

func ReadFullData

func ReadFullData(r io.Reader, data []byte) error

ReadFullData reads len(data) bytes from r.

func RemoveDirContents

func RemoveDirContents(dir string)

RemoveDirContents removes all the contents of the given dir if it exists.

It doesn't remove the dir itself, so the dir may be mounted to a separate partition.

func SymlinkRelative

func SymlinkRelative(srcPath, dstPath string) error

SymlinkRelative creates relative symlink for srcPath in dstPath.

func WriteFileAtomically added in v1.25.0

func WriteFileAtomically(path string, data []byte) error

WriteFileAtomically atomically writes data to the given file path.

WriteFileAtomically returns only after the file is fully written and synced to the underlying storage.

Types

type MustReadAtCloser added in v1.33.0

type MustReadAtCloser interface {
	// MustReadAt must read len(p) bytes from offset off to p.
	MustReadAt(p []byte, off int64)

	// MustClose must close the reader.
	MustClose()
}

MustReadAtCloser is rand-access read interface.

type ReaderAt

type ReaderAt struct {
	// contains filtered or unexported fields
}

ReaderAt implements rand-access reader.

func MustOpenReaderAt added in v1.48.0

func MustOpenReaderAt(path string) *ReaderAt

MustOpenReaderAt opens ReaderAt for reading from filename.

MustClose must be called on the returned ReaderAt when it is no longer needed.

func (*ReaderAt) MustClose

func (r *ReaderAt) MustClose()

MustClose closes r.

func (*ReaderAt) MustFadviseSequentialRead added in v1.33.0

func (r *ReaderAt) MustFadviseSequentialRead(prefetch bool)

MustFadviseSequentialRead hints the OS that f is read mostly sequentially.

if prefetch is set, then the OS is hinted to prefetch f data.

func (*ReaderAt) MustReadAt added in v1.33.0

func (r *ReaderAt) MustReadAt(p []byte, off int64)

MustReadAt reads len(p) bytes at off from r.

Jump to

Keyboard shortcuts

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