Documentation ¶
Index ¶
- func BaseNameWithoutExt(filename string) string
- func Copy(src, dest string) error
- func IsWritable(path string) (isWritable bool, err error)
- func LocateFile(protofile string, protodirs []string) (string, error)
- func Move(src, dst string) error
- func PrepareOutputdir(outputdir string) error
- func UniqFilePath(dirs []string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseNameWithoutExt ¶
BaseNameWithoutExt return basename without extension of `filename`, in which `filename` may contains directory.
func IsWritable ¶
IsWritable test if directory path is writable or not
func LocateFile ¶
LocateFile 定位protofile目录路径
要想保证protofile能够被搜索到,protodirs需要提供protofile的父路径,不能是父路径的父路径
func Move ¶
Move move `src` to `dest`
the behavior of fs.Move is consistent with bash shell `mv` command:
when move a file, actions are following: ------------------------------------------------------------------------------------------------ | No. | src existed | src type | dst existed | dst type | behavior | ------------------------------------------------------------------------------------------------ | 1 | False | - | - | - | error: No such file or directory | ------------------------------------------------------------------------------------------------ | 2 | True | File | False | - | if dir(dst) existed: | | | | | | | - Yes, is dir, mv `src` to dir(dst) | | | | | | | - Yes, not dir, err: Not a directory | | | | | | | - No, err: No such file or directory | ------------------------------------------------------------------------------------------------ | 3 | True | File | True | Folder | if dst/basename(src) existed: | | | | | | | - Yes, mv `src` to dst/basename(src) | | | | | | | - No, mv `src` to dst/basename(src) | ------------------------------------------------------------------------------------------------ | 4 | True | File | True | File | mv `src` to dst | ------------------------------------------------------------------------------------------------
when move a directory, actions are following: ------------------------------------------------------------------------------------------------ | 5 | True | Folder | False | - | if dir(dst) existed: | | | | | | | - Yes, is dir, mv `src` to dir(dst) | | | | | | | - Yes, not dir, err: File Exists | | | | | | | - No, err: No such file or directory | ------------------------------------------------------------------------------------------------ | 6 | True | Folder | True | File | error: File Already Existed | ------------------------------------------------------------------------------------------------ | 7 | True | Folder | True | Folder | t = dst/basename(src), if t existed: | | | | | | | - Yes, t empty, mv src to t | | | | | | | - t notempty, err: t Not empty | | | | | | | - No, mv src to t | ------------------------------------------------------------------------------------------------
Why keep the behavior consistent? It makes the usage much more friendly when it behaves as users expected.
func PrepareOutputdir ¶
PrepareOutputdir create outputdir if it doesn't exist, return error if `outputdir` existed while it is not a directory, return error if any other error occurs.
Types ¶
This section is empty.