files

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 7 Imported by: 2

README

go-files

Open In GitPod GitHub code size in bytes GitHub commit activity GitHub last commit

collection of utility methods that make working with files easier.This package is experimental. use at your own risk. many of these functions were originally found at other repos.mainly, they were taken from prometheus and victoria metrics repos but for a full list of references, refer to doc.go. In case a function has multiple os implementation, for sake of keeping the codebase small, only linux implementation were kept

Documentation

Overview

Package files contains utility functions to make working with files easier and more straight forward acknowledgements

  • github.com/prometheus/prometheus/tsdb/fileutil
  • github.com/VictoriaMetrics/VictoriaMetrics/lib/fs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir added in v0.0.2

func CopyDir(src, dest string) error

CopyDir copies all directories, subdirectories and files recursively

func CopyFile added in v0.0.2

func CopyFile(src, dest string) error

CopyFile copies a file from src to destination

func DirSize added in v0.0.2

func DirSize(dir string) (int64, error)

DirSize returns size of a target directory

func FileSize added in v0.0.2

func FileSize(path string) (int64, error)

FileSize returns file size for the given path.

func HardLinkFiles added in v0.0.2

func HardLinkFiles(src, dest string) error

HardLinkFiles makes hard links for all the files from src in dest.

func IsDirOrSymlink(fi os.FileInfo) bool

IsDirOrSymlink returns true if fi is directory or symlink.

func IsTemporaryFileName added in v0.0.2

func IsTemporaryFileName(fn string) bool

IsTemporaryFileName returns true if fn matches temporary file name pattern

func MkdirAll added in v0.0.2

func MkdirAll(path string) error

MkdirAll creates directory tree and won't return error if it exists

func OpenPath

func OpenPath(path string) (*os.File, os.FileInfo, error)

OpenPath ...

func PathExist added in v0.0.2

func PathExist(path string) bool

PathExist returns whether the given path exists.

func ReadDirFiles added in v0.0.2

func ReadDirFiles(root, pattern string) ([]string, error)

ReadDirFiles searches a root directory recursively for files with a pattern

func Rename added in v0.0.2

func Rename(from, to string) error

Rename safely renames a file.

func SafeMkdirAll added in v0.0.2

func SafeMkdirAll(path string) error

SafeMkdirAll creates directory tree in case it doesn't exist if it exists, it would fail

func SafeOpenPath added in v0.0.2

func SafeOpenPath(path string) (*os.File, os.FileInfo, error)

SafeOpenPath removes empty files after opening empty files are most often result of a failed io

func SymlinkRelative added in v0.0.2

func SymlinkRelative(srcPath, dstPath string) error

SymlinkRelative creates relative symlink for srcPath in dstPath.

func SyncPath added in v0.0.2

func SyncPath(path string) error

SyncPath makes sure file at a certain path is synced with physical disk

Types

This section is empty.

Jump to

Keyboard shortcuts

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