Documentation ¶
Index ¶
- Constants
- func CopyFile(src string, dst string) (err error)
- func CreateDirectory(dirPath string) error
- func DeleteFile(filePath string) error
- func DeleteFiles(filePaths ...string)
- func FsizeToString(fsize Fsize) string
- func GetMd5Sum(md5 hash.Hash, b []byte) string
- func GetSys(info os.FileInfo) (*syscall.Stat_t, bool)
- func IsDir(name string) bool
- func IsEmptyDir(path string) (bool, error)
- func IsRegularFile(name string) bool
- func Link(src string, linkName string) error
- func LoadYaml(path string, out interface{}) error
- func Md5Sum(name string) string
- func MoveFile(src string, dst string) error
- func MoveFileAfterCheckMd5(src string, dst string, md5 string) error
- func OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)
- func PathExist(name string) bool
- func SymbolicLink(src string, target string) error
- type FileLock
- type Fsize
Constants ¶
const ( B Fsize = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB )
const BufferSize = 8 * 1024 * 1024
BufferSize defines the buffer size when reading and writing file.
Variables ¶
This section is empty.
Functions ¶
func CreateDirectory ¶
CreateDirectory creates directory recursively.
func FsizeToString ¶ added in v1.0.0
FsizeToString parses a Fsize value into string.
func GetMd5Sum ¶ added in v1.0.0
GetMd5Sum gets md5 sum as a string and appends the current hash to b.
func IsEmptyDir ¶ added in v1.0.3
IsEmptyDir check whether the directory is empty.
func IsRegularFile ¶
IsRegularFile reports whether the file is a regular file. If the given file is a symbol link, it will follow the link.
func MoveFileAfterCheckMd5 ¶
MoveFileAfterCheckMd5 will check whether the file's md5 is equals to the param md5 before move the file src to dst.
func OpenFile ¶
OpenFile opens a file. If the parent directory of the file isn't exist, it will create the directory.
func PathExist ¶
PathExist reports whether the path is exist. Any error get from os.Stat, it will return false.
func SymbolicLink ¶
SymbolicLink creates target as a symbolic link to src.
Types ¶
type FileLock ¶ added in v1.0.0
type FileLock struct {
// contains filtered or unexported fields
}
FileLock defines a file lock implemented by syscall.Flock
func NewFileLock ¶ added in v1.0.0
NewFileLock create a FileLock instance
type Fsize ¶ added in v1.0.0
type Fsize int64
Fsize is a wrapper type which indicates the file size.
func GetFreeSpace ¶ added in v1.0.0
GetFreeSpace gets the free disk space of the path.
func StringToFSize ¶ added in v1.0.0
StringToFSize parses a string into Fsize.
func (Fsize) MarshalYAML ¶ added in v1.0.0
MarshalYAML implements the yaml.Marshaler interface.
func (*Fsize) UnmarshalYAML ¶ added in v1.0.0
UnmarshalYAML implements the yaml.Unmarshaler interface.