filex

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterFileRead

func AfterFileRead(filename string, callback func([]byte) error) error

AfterFileRead is a function that executes a function when a file is read.

func CopyDir

func CopyDir(src, dst string, overwrite ...bool) error

CopyDir copies a directory from src to dst. returns an error if something goes wrong. if overwrite slice is not empty, the first one will be used to determine if the file should be overwritten.

func CopyFile

func CopyFile(src, dst string, overwrite ...bool) error

CopyFile copies a file from src to dst. returns an error if something goes wrong. if overwrite slice is not empty, the first one will be used to determine if the file should be overwritten.

func CreateFileFromByteFn

func CreateFileFromByteFn(filename string, overwrite bool, f func() []byte) error

CreateFileFromByteFn creates a file from the functionx that returns a byte slice.

func CreateFileFromBytes

func CreateFileFromBytes(file string, overwrite bool, content []byte) error

CreateFileFromBytes creates a file from the byte slice.

func CreateFileFromReader

func CreateFileFromReader(file string, overwrite bool, reader io.Reader) error

CreateFileFromReader creates a file from the reader.

func CreateFileFromString

func CreateFileFromString(file string, overwrite bool, content string) error

CreateFileFromString creates a file from the string.

func CreateFileFromWriterFunc

func CreateFileFromWriterFunc(file string, overwrite bool, fn func(w io.Writer) error) error

CreateFileFromWriterFunc creates a file from the functionx that returns a writer.

func DeleteDir

func DeleteDir(dir string) error

DeleteDir deletes a directory.

func DeleteDirFn

func DeleteDirFn(dir string, fn func() error) error

DeleteDirFn executes the functionx if the directory is deleted.

func DeleteFile

func DeleteFile(file string) error

DeleteFile deletes a file.

func DeleteFileFn

func DeleteFileFn(file string, fn func() error) error

DeleteFileFn executes the functionx if the file is deleted.

func Extension

func Extension(filePath string) string

Extension returns the extension of the file name

func Getwd

func Getwd() string

func IfExists

func IfExists(path string, fn func(path string) error) error

IfExists checks if the file exists and executes the functionx.

func IfIsDir

func IfIsDir(path string, f func() error) error

IfIsDir executes the given functionx if the given path is a directory. an error is returned if execution fails.

func IfIsFile

func IfIsFile(path string, f func(p string) error) error

IfIsFile executes the given functionx if the given path is a file. an error is returned if execution fails.

func IfIsRegular

func IfIsRegular(path string, fn func() error) error

IfIsRegular executes the functionx if the file is a regular file. returns error if execution fails.

func IfNotExists

func IfNotExists(path string, fn func(path string) error) error

IfNotExists executes the functionx if the file does not exist. returns error if execution fails.

func IsDir

func IsDir(path string) bool

IsDir checks if the given path is a directory.

func IsEmptyDir

func IsEmptyDir(path string) bool

func IsExists

func IsExists(path string) bool

IsExists returns true if the file exists.

func IsFile

func IsFile(path string) bool

IsFile checks if the given path is a file.

func IsNotExists

func IsNotExists(path string) bool

IsNotExists returns true if the file does not exist.

func IsReadableFile added in v0.1.10

func IsReadableFile(path string) (bool, error)

func IsRegular

func IsRegular(path string) bool

IsRegular returns true if the file is a regular file.

func IsSubDir

func IsSubDir(parent, child string) bool

IsSubDir checks if the given path is a subdirectory of the given parent.

func IsSymlink(path string) bool

IsSymlink returns true if the file is a symlink.

func MatchPattern

func MatchPattern(patterns []string, name string) bool

MatchPattern returns true if the filepath matches any of the patterns.

func MkdirIfNotExist

func MkdirIfNotExist(dir string) error

MkdirIfNotExist creates a directory if it does not exist.

Types

This section is empty.

Jump to

Keyboard shortcuts

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