tsdb: github.com/prometheus/tsdb/fileutil Index | Files

package fileutil

import "github.com/prometheus/tsdb/fileutil"

Package fileutil provides utility methods used when dealing with the filesystem in tsdb. It is largely copied from github.com/coreos/etcd/pkg/fileutil to avoid the dependency chain it brings with it. Please check github.com/coreos/etcd for licensing information.


Package Files

dir_unix.go fileutil.go flock.go flock_unix.go mmap.go mmap_unix.go preallocate.go preallocate_linux.go sync_linux.go

func CopyDirs Uses

func CopyDirs(src, dest string) error

CopyDirs copies all directories, subdirectories and files recursively including the empty folders. Source and destination must be full paths.

func Fdatasync Uses

func Fdatasync(f *os.File) error

Fdatasync is similar to fsync(), but does not flush modified metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled.

func OpenDir Uses

func OpenDir(path string) (*os.File, error)

OpenDir opens a directory for syncing.

func Preallocate Uses

func Preallocate(f *os.File, sizeInBytes int64, extendFile bool) 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 ReadDir Uses

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

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

func Rename Uses

func Rename(from, to string) error

Rename safely renames a file.

func Replace Uses

func Replace(from, to string) error

Replace moves a file or directory to a new location and deletes any previous data. It is not atomic.

type MmapFile Uses

type MmapFile struct {
    // contains filtered or unexported fields

func OpenMmapFile Uses

func OpenMmapFile(path string) (*MmapFile, error)

func (*MmapFile) Bytes Uses

func (f *MmapFile) Bytes() []byte

func (*MmapFile) Close Uses

func (f *MmapFile) Close() error

func (*MmapFile) File Uses

func (f *MmapFile) File() *os.File

type Releaser Uses

type Releaser interface {
    Release() error

Releaser provides the Release method to release a file lock.

func Flock Uses

func Flock(fileName string) (r Releaser, existed bool, err error)

Flock locks the file with the provided name. If the file does not exist, it is created. The returned Releaser is used to release the lock. existed is true if the file to lock already existed. A non-nil error is returned if the locking has failed. Neither this function nor the returned Releaser is goroutine-safe.

Package fileutil imports 9 packages (graph) and is imported by 105 packages. Updated 2019-07-25. Refresh now. Tools for package owners.