filex

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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.

func WhenFileRead

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

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

Types

type Chunk

type Chunk struct {
	Number uint   // Chunk number
	Offset uint64 // Chunk offset
	Size   uint64 // Chunk size.
}

type SplitFile

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

func NewSplitFile

func NewSplitFile(path string) (*SplitFile, error)

NewSplitFile creates a new SplitFile.

func NewSplitFileBySize

func NewSplitFileBySize(size uint64) (*SplitFile, error)

NewSplitFileBySize create a new SplitFile by size.

func (*SplitFile) SplitFileByChunkNum

func (c *SplitFile) SplitFileByChunkNum(chunkNum uint) ([]Chunk, error)

SplitFileByChunkNum splits a file into chunks by chunk number.

func (*SplitFile) SplitFileByChunkSize

func (c *SplitFile) SplitFileByChunkSize(chunkSize uint) ([]Chunk, error)

SplitFileByChunkSize splits a file into chunks by chunk size.

Jump to

Keyboard shortcuts

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