Documentation ¶
Overview ¶
Package manager is the core package that contacts directly with the file system
Index ¶
- func CopyDir(src, dst string) (err error)
- func CopyFile(src, dst string) (err error)
- func CreateDir(fullDirPath string, parents bool) (err error)
- func CreateFile(fullFilePath string) (*os.File, error)
- func Remove(fullPath string, recursive bool) (err error)
- func Rename(oldpath, newpath string) (err error)
- func ZipDir(dirPath string, w io.Writer) (err error)
- type FileProperty
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDir ¶
CopyDir copies a directory and its children recursively Terminates when it meets an error (no fall back)
func CopyFile ¶
CopyFile copies a file from src to dst. If `src` and `dst` files exist, and are the same, then return success. Otherwise, attempt to create a hard link between the two files. If that fails, copy the file contents from src to dst.
func CreateDir ¶
CreateDir creates new a new directory It creates parents directory if needed when `parents` is `true` It is similar to `mkdir -p`
func CreateFile ¶
CreateFile creates a new file. If the file is already exists of the directory does not exists, it will return an error
Types ¶
type FileProperty ¶
type FileProperty struct { Name string `json:"name"` Size int64 `json:"size"` Mode string `json:"mode"` ModTime string `json:"modTime"` IsDir bool `json:"isDir"` }
FileProperty is a data structure whichdescribes a file It is part of the result for list api
func ListDir ¶
func ListDir(dir string, all bool, max int, ext string) (results []FileProperty, total int, err error)
ListDir returns all files and/or directories infomation of a specified path and count of all f/d rather than the count of the returned files. Caveats: the size of directory is solid, which is the size of the directory itself, not including what is inside the directory. Calculating the total size of a certain directory needs the program to calculate the sizes of all its sub contents recursively, which costs too much time and memory. It is not necessary to make this calculation.