Documentation ¶
Overview ¶
inspiring from https://www.youtube.com/watch?v=1B71SL6Y0kA
Index ¶
- Constants
- Variables
- func Check(src string) error
- func CheckExist(src string) bool
- func CheckNotExist(src string) bool
- func CheckPermission(src string) bool
- func CopyDir(src, dst string) error
- func CopyFile(src, dst string) error
- func CreatFileFromReader(filepath string, reader io.Reader) error
- func CreatFileFromReaderIfNotExists(filepath string, reader io.Reader) error
- func Create(filepath string) (*os.File, error)
- func DirsDeDuplicate(dirs ...string) error
- func DirsDuplicateHandle(callback func(path1, path2 string) error, dirs ...string) error
- func DirsRangeDuplicateHandle(rangeCallback func(dir string, entry os.DirEntry) (error, bool), ...) error
- func Exist(filepath string) bool
- func FindFile(path string) (string, error)
- func FindFiles(path string, deep int8, num int) ([]string, error)
- func FindFiles2(path string, deep int8, num int) ([]string, error)
- func GetFileCreateTime(path string) int64
- func GetLogFilePath(RuntimeRootPath, LogSavePath string) string
- func GetMd5Name(name string) string
- func Inspect(dir string, file func(string, os.DirEntry) bool) error
- func LastFile(dir string) (os.FileInfo, map[string]os.FileInfo, error)
- func Md5(path string) (string, error)
- func Md5Equal(path1, path2 string) (bool, error)
- func Mkdir(src string) error
- func MkdirAll(src string) error
- func Move(src, dst string) error
- func MustOpen(fileName, filePath string) (*os.File, error)
- func NotExist(filepath string) bool
- func Open(filepath string) (*os.File, error)
- func OpenLogFile(fileName, filePath string) (*os.File, error)
- func Range(dir string, callback FileRangeCallback) error
- func RangeDir(dir string, ...) error
- func RangeFile(dir string, callback FileRangeCallback) error
- func SafeCopyFile(src, dst string) error
- func Sync(mainDir, slaveDir string) error
- func TwoDirDeDuplicate(dir1, dir2 string) error
- func TwoDirDuplicateHandle(dir1, dir2 string, callback func(path1, path2 string) error) error
- func Walk(root string, fn filepath.WalkFunc) error
- func WalkDir(root string, fn fs.WalkDirFunc) error
- func WalkDirWithFS(fsys fs.FS, root string, fn fs.WalkDirFunc) error
- func Write(data []byte, filename string) (n int, err error)
- func WriteBuffer(buf *bytes.Buffer, filename string) (n int, err error)
- type Dir
- type DirEntries
- type FileRangeCallback
- type FileSize
- type FileType
- type SafeCopy
- type Visitor
Constants ¶
View Source
const DownloadKey = ".downloading"
View Source
const PathSeparator = string(os.PathSeparator)
Variables ¶
View Source
var FileTypeMap = map[string]FileType{ ".txt": Txt, ".doc": Doc, }
Functions ¶
func CheckExist ¶
func CheckNotExist ¶
func CheckPermission ¶
func DirsDuplicateHandle ¶
func DirsRangeDuplicateHandle ¶
func DirsRangeDuplicateHandle(rangeCallback func(dir string, entry os.DirEntry) (error, bool), duplicateCallback func(path1, path2 string) error, dirs ...string) error
DirsRangeDuplicateHandle rangeCallback 返回值为错误和是否继续
func FindFiles2 ¶
path和filepath两个包,filepath文件专用
func GetFileCreateTime ¶
func GetLogFilePath ¶
func GetMd5Name ¶
func Range ¶
func Range(dir string, callback FileRangeCallback) error
遍历根目录中的每个文件,为每个文件调用callback,包括文件夹,与filepath.WalkDir不同的是回调函数的参数不同,filepath.WalkDir的第一个参数是文件完整路径,RangeFile是文件所在目录的路径
func RangeDir ¶
func RangeDir(dir string, callback func(dir string, entries []os.DirEntry) ([]os.DirEntry, error)) error
RangeDir 遍历根目录中的每个文件夹,为文件夹调用callback callback 返回值为需要递归遍历的目录和error 几乎每个文件夹下的文件夹都会被循环两次!
func RangeFile ¶
func RangeFile(dir string, callback FileRangeCallback) error
遍历根目录中的每个文件,为每个文件调用callback,不包括文件夹,与filepath.WalkDir不同的是回调函数的参数不同,filepath.WalkDir的第一个参数是文件完整路径,RangeFile是文件所在目录的路径
func SafeCopyFile ¶
SafeCopyFile : Error handling by abstraction
func TwoDirDuplicateHandle ¶
func WalkDirWithFS ¶
Types ¶
type DirEntries ¶
func (DirEntries) Len ¶
func (e DirEntries) Len() int
func (DirEntries) Less ¶
func (e DirEntries) Less(i, j int) bool
func (DirEntries) Swap ¶
func (e DirEntries) Swap(i, j int)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.