ioutilmore

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseFileWithError added in v1.2.0

func CloseFileWithError(file *os.File, err error) error

func CopyFile

func CopyFile(src, dst string) (err error)

func DirEntriesNameRxVarFirsts

func DirEntriesNameRxVarFirsts(dir string, rx1 *regexp.Regexp) ([]string, error)

DirEntriesNameRxVarFirsts returns a slice of the first regexp match encountered.

func DirEntriesRxSizeGt0

func DirEntriesRxSizeGt0(dir string, fileFilter FileType, rx1 *regexp.Regexp) ([]os.FileInfo, error)

func DirEntriesRxSizeGt0Filepaths

func DirEntriesRxSizeGt0Filepaths(dir string, fileFilter FileType, rx *regexp.Regexp) ([]string, error)

func DirFilesRegexpSubmatchGreatest

func DirFilesRegexpSubmatchGreatest(dir string, rx1 *regexp.Regexp, nonZeroFilesOnly bool) ([]os.FileInfo, error)

DirEntriesRegexpGreatest takes a directory, regular expression and boolean to indicate whether to include zero size files and returns the greatest of a single match in the regular expression.

func DirFilesRegexpSubmatchGreatestSubmatch

func DirFilesRegexpSubmatchGreatestSubmatch(dir string, rx1 *regexp.Regexp, nonZeroFilesOnly bool) (string, error)

DirFilesRegexpSubmatchGreatestSubmatch takes a directory, regular expression and boolean to indicate whether to include zero size files and returns the greatest of a single match in the regular expression.

func DirFromPath

func DirFromPath(path string) (string, error)

func Exists

func Exists(name string) (bool, error)

func FileInfosSplit

func FileInfosSplit(all []os.FileInfo, inclDotDirs bool) ([]os.FileInfo, []os.FileInfo)

func FileinfosNames

func FileinfosNames(fis []os.FileInfo) []string

func FileinfosToFilepaths

func FileinfosToFilepaths(dir string, fileInfos []os.FileInfo) []string

func FilepathModAgeGTE

func FilepathModAgeGTE(path string, s string) (bool, error)

func FilepathModAgeLTE

func FilepathModAgeLTE(path string, s string) (bool, error)

func FilterFilenamesSizeGtZero

func FilterFilenamesSizeGtZero(filepaths ...string) []string

func GetFileModAge

func GetFileModAge(fi os.FileInfo) (time.Duration, error)

func GetFilepathModAge

func GetFilepathModAge(path string) (time.Duration, error)

func IsDir

func IsDir(name string) (bool, error)

func IsFile

func IsFile(name string) (bool, error)

func IsFileWithSizeGtZero

func IsFileWithSizeGtZero(name string) (bool, error)

IsFileWithSizeGtZero verifies a path exists, is a file and is not empty, returning an error otherwise. An os file not exists check can be done with os.IsNotExist(err) which acts on error from os.Stat()

func ReadDirRx added in v1.1.0

func ReadDirRx(dir string, rx *regexp.Regexp, skipEmpty bool) ([]os.FileInfo, []string, error)

func ReadDirSplit

func ReadDirSplit(dirname string, inclDotDirs bool) ([]os.FileInfo, []os.FileInfo, error)

func ReadFileJSON

func ReadFileJSON(file string, v interface{}) error

ReadFileJSON reads and unmarshals a file.

func ReaderToBytes

func ReaderToBytes(ior io.Reader) []byte

ReaderToBytes reads from an io.Reader, e.g. io.ReadCloser

func RemoveAllChildren

func RemoveAllChildren(dir string) error

func SplitBest

func SplitBest(path string) (dir, file string, err error)

func SplitBetter

func SplitBetter(path string) (dir, file string)

func WriteFileJSON

func WriteFileJSON(filepath string, data interface{}, perm os.FileMode, prefix, indent string) error

Types

type FileInfoMore

type FileInfoMore struct {
	FileInfo os.FileInfo
	ModAge   time.Duration
}

func NewFileInfoMoreFromPath

func NewFileInfoMoreFromPath(path string) (FileInfoMore, error)

type FileType

type FileType int
const (
	File FileType = iota
	Directory
	Any
)

type FileWriter

type FileWriter struct {
	File   *os.File
	Writer *bufio.Writer
}

func NewFileWriter

func NewFileWriter(path string) (FileWriter, error)

func (*FileWriter) Close

func (f *FileWriter) Close()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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