Documentation
¶
Index ¶
- func CombineCmdArgs(args ...interface{}) []string
- func CopyFile(src, dst string) (err error)
- func CopyFileLazy(src, dst string) error
- func DirExists(path string) (ex bool, err error)
- func Exists(path string) (ex bool, err error)
- func FileExists(path string) (ex bool, err error)
- func FileExt(filepath string) string
- func MoveFile(src, dst string) error
- func MoveFileLazy(src, dst string) error
- func RunCmd(cmd *exec.Cmd) bool
- func SameContents(src, dst string) (same bool, err error)
- func SameFile(src, dst string) (same bool, err error)
- type FileTypeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombineCmdArgs ¶
func CombineCmdArgs(args ...interface{}) []string
CombineCmdArgs puts the given arguments all in a slice. If one of the arguments is a string, then it is split by spaces, and if it is a slice, then the elements are added to the slice. This is all returned.
Warning: this is a very obscure and weird function (it's already bitten me once), so be careful.
func CopyFile ¶
CopyFile tries to copy src to dst. If dst already exists, it will be overwritten. If it does not exist, it will be created.
func CopyFileLazy ¶
CopyFileLazy is the same as CopyFile, except that it avoids copying the file when the destination already has the same contents.
func DirExists ¶
DirExists returns ex = true if the file exists and is a directory, and returns err != nil if any other error occured (such as permission denied).
func Exists ¶
Exists returns ex = true if the given file exists, regardless whether it is a file or a directory. Normally you will probably want to use the more specific versions: FileExists and DirectoryExists.
func FileExists ¶
FileExists returns ex = true if the file exists and is not a directory, and returns err != nil if any other error occured (such as permission denied).
func FileExt ¶
FileExt returns the file type as identified by the (lowercase) extension. As such it is very limited, but for limited purposes, simple enough.
func MoveFileLazy ¶
MoveFileLazy is the same as MoveFile, except that it avoids copying the file when the destination already has the same contents.
func RunCmd ¶
RunCmd runs the command and returns whether it completed correctly or not. If any error occurs, then the entire output is printed to the log file.
func SameContents ¶
SameContents returns same = true if src and dst both exist and have the same file contents. Whether the file data is at the same place on disk is a different question, which is not answered.
If either file is a directory, FileTypeError is returned.
Types ¶
type FileTypeError ¶
type FileTypeError struct {
Filepath string
}
func (FileTypeError) Error ¶
func (e FileTypeError) Error() string