file

package
v0.0.0-...-dddd691 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	All  int = 0
	File int = 1
	Dir  int = 2
)

Variables

This section is empty.

Functions

func CloneDir

func CloneDir(fromDir, toDir string, replaceSame bool, filter func(filePath string) bool) (targetFiles []string, e error)

将from文件夹下面的文件,全部clone到toDir,例如传入./a/, ./b/, 则 ./a/c.txt 会clone到 ./b/c.txt

func CloneFile

func CloneFile(from, to string) (e error)

func DeletePath

func DeletePath(path string) int

func EnsureDir

func EnsureDir(dir string) error

func GetDirChildren

func GetDirChildren(dirPath string, flag int) []string

0,all kind 1.only file 2.only dir

func GetExecFileDir

func GetExecFileDir() (dir string, err error)

func IsDirExists

func IsDirExists(path string) bool

func IsFileExists

func IsFileExists(path string) bool

func ReadFile

func ReadFile(path string, offset, leng int64) (content []byte, err error)

func WriteFile

func WriteFile(path string, data []byte, createIfNoFile bool, overrideOrAppend bool) error

Types

type FileFilter

type FileFilter func(path, name, suffix string, isFile bool, size, modTime int64, level int) bool
var FileFilterAllAccept FileFilter = func(path, name, suffix string, isFile bool, size, modTime int64, level int) bool { return true }

type FileInfo

type FileInfo struct {
	Path, Name, Suffix string
	IsFile             bool
	Size, ModTime      int64
	Level              int
}

type FileInfoFilter

type FileInfoFilter func(FileInfo) bool

type FileTree

type FileTree map[string]FileTree

func GetDirChildrenWithFilter

func GetDirChildrenWithFilter(dirPath string, maxLevel int, filter FileFilter) FileTree

func WalkFiles

func WalkFiles(dirPath string, maxLevel int, filter FileInfoFilter) FileTree

func (FileTree) GetFiles

func (this FileTree) GetFiles() []string

type FolderStruct

type FolderStruct struct {
	Name     string         `json:"name,omitempty"`
	IsDir    bool           `json:"isDir,omitempty"`
	Size     int64          `json:"size,omitempty"`
	ModifyAt int64          `json:"modifyAt,omitempty"`
	Children []FolderStruct `json:"children,omitempty"`
}

func GetFolderStruct

func GetFolderStruct(dirPath string, maxLevel int) FolderStruct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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