zfile

package
v1.7.12 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 15 Imported by: 31

Documentation

Overview

Package zfile file and path operations in daily development

Index

Constants

This section is empty.

Variables

View Source
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 CopyFile added in v0.0.19

func CopyFile(source string, dest string) (err error)

CopyFile copies the source file to the dest file.

func DirExist

func DirExist(path string) bool

DirExist Is it an existing directory

func FileExist

func FileExist(path string) bool

FileExist Is it an existing file?

func FileSize

func FileSize(file string) (size string)

FileSize file size

func FileSizeUint added in v1.2.0

func FileSizeUint(file string) (size uint64)

FileSizeUint file size to uint64

func GetMimeType added in v1.4.5

func GetMimeType(filename string, content []byte) (ctype string)

GetMimeType get file mime type

func GzCompress added in v0.1.45

func GzCompress(currentPath, dest string) (err error)

GzCompress use gzip to compress to tar.gz

func GzDeCompress added in v0.1.45

func GzDeCompress(tarFile, dest string) error

GzDeCompress unzip tar.gz

func IsSubPath added in v1.4.10

func IsSubPath(subPath, path string) bool

IsSubPath Is the subPath under the path

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 MoveFile added in v1.2.0

func MoveFile(source string, dest string, force ...bool) error

MoveFile Move File

func PathExist

func PathExist(path string) (int, error)

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

func ProgramPath(addSlash ...bool) (path string)

ProgramPath program directory path

func PutAppend added in v0.1.19

func PutAppend(path string, b []byte) (err error)

PutAppend open the specified file and write data at the end of the file

func PutOffset added in v0.1.19

func PutOffset(path string, b []byte, offset int64) (err error)

PutOffset open the specified file and write data from the specified location

func ReadFile added in v0.1.43

func ReadFile(path string) ([]byte, error)

ReadFile ReadFile

func ReadLineFile added in v0.1.54

func ReadLineFile(path string, handle func(line int, data []byte) error) (err error)

ReadLineFile ReadLineFile

func RealPath added in v0.0.19

func RealPath(path string, addSlash ...bool) (realPath string)

RealPath get an absolute path

func RealPathMkdir added in v0.0.19

func RealPathMkdir(path string, addSlash ...bool) string

RealPathMkdir get an absolute path, create it if it doesn't exist

func Remove added in v1.2.0

func Remove(path string) error

Remove removes the named file or (empty) directory

func Rmdir added in v0.0.19

func Rmdir(path string, notIncludeSelf ...bool) (ok bool)

Rmdir support to keep the current directory

func RootPath added in v0.0.23

func RootPath() string

RootPath Project Launch Path

func SafePath added in v0.0.23

func SafePath(path string, pathRange ...string) string

SafePath get an safe absolute path

func SizeFormat added in v0.1.60

func SizeFormat(s uint64) string

SizeFormat Format file size

func TmpPath added in v0.1.45

func TmpPath(pattern ...string) string

func WriteFile added in v0.1.43

func WriteFile(path string, b []byte, isAppend ...bool) (err error)

WriteFile WriteFile

func ZipCompress added in v0.1.45

func ZipCompress(currentPath, dest string) (err error)

ZipCompress zip

func ZipDeCompress added in v0.1.45

func ZipDeCompress(zipFile, dest string) error

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) Read added in v1.2.0

func (f *MemoryFile) Read(buffer []byte) (int, error)

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) Stat added in v1.2.0

func (f *MemoryFile) Stat() (os.FileInfo, error)

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{}

func (*MemoryFile) Write added in v1.2.0

func (f *MemoryFile) Write(buffer []byte) (int, error)

type MemoryFileOption added in v1.2.0

type MemoryFileOption func(*MemoryFile)

Jump to

Keyboard shortcuts

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