Documentation ¶
Index ¶
- func CopyFile(src, dst string, replace, jump bool) error
- func CopyFiles(src, dst string, replace, jump bool, walk WalkCallback) error
- func FormatFileSize(fileSize int64) (size string)
- func GetCreateTime(path string) (time.Time, error)
- func GetDirList(path string) ([]string, error)
- func GetFileInfo(path string) (os.FileInfo, error)
- func GetFileSize(path string) (int64, error)
- func GetModifyTime(path string) (time.Time, error)
- func GetSHA256(r io.Reader) (string, error)
- func GetWriter(path string) (*os.File, error)
- func IsAcrossDiskError(err error) bool
- func IsDir(path string) bool
- func IsExist(path string) bool
- func IsExistError(err error) bool
- func IsFile(path string) bool
- func IsNotExistError(err error) bool
- func Mkdir(path string) error
- func MkdirAll(path string) error
- func MoveFiles(src, dst string, replace, jump bool) error
- func MoveFilesAcrossDisk(src, dst string, replace, jump bool, walk WalkCallback) error
- func MoveFilesByCopying(src, dst string, replace, jump bool, walk WalkCallback) error
- func OpenFile(path string) (*os.File, error)
- func PathExist(op, path string) error
- func PathNotExist(op, path string) error
- func ReadFileAsJSON(path string, v interface{}) error
- func ReadFileAsText(path string) (string, error)
- func RemoveAll(file string) error
- func RemoveFile(file string) error
- func Rename(old, newName string) error
- func WriteFileAsJSON(path string, v interface{}) error
- func WriteTextFile(path, text string) error
- type WalkCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFiles ¶
func CopyFiles(src, dst string, replace, jump bool, walk WalkCallback) error
CopyFiles 复制文件夹 (源路径, 目标路径, 重复覆盖, 重复忽略, 每个路径操作结果回调(可以nil)) walk 返回err则停止下一个拷贝
func FormatFileSize ¶
FormatFileSize 字节的单位转换 保留两位小数
func GetWriter ¶
GetWriter 获取只写文件对象 O_RDONLY: 只读模式(read-only) O_WRONLY: 只写模式(write-only) O_RDWR: 读写模式(read-write) O_APPEND: 追加模式(append) O_CREATE: 文件不存在就创建(create a new file if none exists.) O_EXCL: 与 O_CREATE 一起用, 构成一个新建文件的功能, 它要求文件必须不存在 O_SYNC: 同步方式打开,即不使用缓存,直接写入硬盘 O_TRUNC: 打开并清空文件
func MoveFilesAcrossDisk ¶
func MoveFilesAcrossDisk(src, dst string, replace, jump bool, walk WalkCallback) error
MoveFilesAcrossDisk 移动文件|文件夹,可跨分区移动(源路径, 目标路径, 重复覆盖, 重复忽略, 每个路径操作结果回调(可以nil))
func MoveFilesByCopying ¶
func MoveFilesByCopying(src, dst string, replace, jump bool, walk WalkCallback) error
MoveFilesByCopying 移动文件|夹(拷贝+删除) (源路径, 目标路径, 重复覆盖, 重复忽略, 每个路径操作结果回调(可以nil))
func WriteFileAsJSON ¶
WriteFileAsJSON 写入Json文件
Types ¶
type WalkCallback ¶
WalkCallback (源路径, 目标路径, 错误信息) 错误. 子文件操作回调 一般用于子文件操作时间较长的操作, 如: MoveFilesAcrossDisk, MoveFilesByCopying, CopyFiles. 返回 非空error则终止下一步操作