Documentation ¶
Overview ¶
Package zfile file and path operations in daily development
Index ¶
- Variables
- func CopyDir(source string, dest string, ...) (err error)
- func CopyFile(source string, dest string) (err error)
- func DirExist(path string) bool
- func FileExist(path string) bool
- func FileSize(file string) (size string)
- func FileSizeUint(file string) (size uint64)
- func GzCompress(currentPath, dest string) (err error)
- func GzDeCompress(tarFile, dest string) error
- func MemoryFileAutoFlush(second int64) func(*MemoryFile)
- func MemoryFileFlushBefore(fn memoryFileFlushBefore) func(*MemoryFile)
- func MoveFile(source string, dest string, force ...bool) error
- func PathExist(path string) (int, error)
- func ProgramPath(addSlash ...bool) (path string)
- func PutAppend(path string, b []byte) (err error)
- func PutOffset(path string, b []byte, offset int64) (err error)
- func ReadFile(path string) ([]byte, error)
- func ReadLineFile(path string, handle func(line int, data []byte) error) (err error)
- func RealPath(path string, addSlash ...bool) (realPath string)
- func RealPathMkdir(path string, addSlash ...bool) string
- func Remove(path string) error
- func Rmdir(path string, notIncludeSelf ...bool) (ok bool)
- func RootPath() string
- func SafePath(path string, pathRange ...string) string
- func SizeFormat(s uint64) string
- func TmpPath(pattern ...string) string
- func WriteFile(path string, b []byte, isAppend ...bool) (err error)
- func ZipCompress(currentPath, dest string) (err error)
- func ZipDeCompress(zipFile, dest string) error
- type MemoryFile
- func (f *MemoryFile) Bytes() []byte
- func (f *MemoryFile) Close() error
- func (f *MemoryFile) IsDir() bool
- func (f *MemoryFile) ModTime() time.Time
- func (f *MemoryFile) Mode() os.FileMode
- func (f *MemoryFile) Name() string
- func (f *MemoryFile) Read(buffer []byte) (int, error)
- func (f *MemoryFile) Seek(offset int64, whence int) (int64, error)
- func (f *MemoryFile) SetName(name string)
- func (f *MemoryFile) Size() int64
- func (f *MemoryFile) Stat() (fs.FileInfo, error)
- func (f *MemoryFile) Sync() error
- func (f *MemoryFile) Sys() interface{}
- func (f *MemoryFile) Write(buffer []byte) (int, error)
- type MemoryFileOption
Constants ¶
This section is empty.
Variables ¶
var (
ProjectPath = "."
)
Functions ¶
func CopyDir ¶ added in v0.0.19
func CopyDir(source string, dest string, filterFn ...func(srcFilePath, destFilePath string) bool) (err error)
CopyDir copies the source directory to the dest directory.
func FileSizeUint ¶ added in v1.2.0
FileSizeUint file size to uint64
func GzCompress ¶ added in v0.1.45
GzCompress use gzip to compress to tar.gz
func GzDeCompress ¶ added in v0.1.45
GzDeCompress unzip tar.gz
func MemoryFileAutoFlush ¶ added in v1.2.0
func MemoryFileAutoFlush(second int64) func(*MemoryFile)
func MemoryFileFlushBefore ¶ added in v1.2.0
func MemoryFileFlushBefore(fn memoryFileFlushBefore) func(*MemoryFile)
MemoryFileFlushBefore is a function that will be called before flush to disk,take care to avoid writing to prevent deadlocks
func PathExist ¶
PathExist PathExist 1 exists and is a directory path, 2 exists and is a file path, 0 does not exist
func ProgramPath ¶ added in v0.0.19
ProgramPath program directory path
func PutAppend ¶ added in v0.1.19
PutAppend open the specified file and write data at the end of the file
func PutOffset ¶ added in v0.1.19
PutOffset open the specified file and write data from the specified location
func ReadLineFile ¶ added in v0.1.54
ReadLineFile ReadLineFile
func RealPathMkdir ¶ added in v0.0.19
RealPathMkdir get an absolute path, create it if it doesn't exist
func ZipCompress ¶ added in v0.1.45
ZipCompress zip
func ZipDeCompress ¶ added in v0.1.45
Types ¶
type MemoryFile ¶ added in v1.2.0
type MemoryFile struct {
// contains filtered or unexported fields
}
func NewMemoryFile ¶ added in v1.2.0
func NewMemoryFile(name string, opt ...MemoryFileOption) *MemoryFile
func (*MemoryFile) Bytes ¶ added in v1.2.0
func (f *MemoryFile) Bytes() []byte
func (*MemoryFile) Close ¶ added in v1.2.0
func (f *MemoryFile) Close() error
func (*MemoryFile) IsDir ¶ added in v1.2.0
func (f *MemoryFile) IsDir() bool
func (*MemoryFile) ModTime ¶ added in v1.2.0
func (f *MemoryFile) ModTime() time.Time
func (*MemoryFile) Mode ¶ added in v1.2.0
func (f *MemoryFile) Mode() os.FileMode
func (*MemoryFile) Name ¶ added in v1.2.0
func (f *MemoryFile) Name() string
func (*MemoryFile) Seek ¶ added in v1.2.0
func (f *MemoryFile) Seek(offset int64, whence int) (int64, error)
func (*MemoryFile) SetName ¶ added in v1.2.0
func (f *MemoryFile) SetName(name string)
func (*MemoryFile) Size ¶ added in v1.2.0
func (f *MemoryFile) Size() int64
func (*MemoryFile) Sync ¶ added in v1.2.0
func (f *MemoryFile) Sync() error
func (*MemoryFile) Sys ¶ added in v1.2.0
func (f *MemoryFile) Sys() interface{}
type MemoryFileOption ¶ added in v1.2.0
type MemoryFileOption func(*MemoryFile)