Documentation ¶
Index ¶
- func ArchiveFiles(sources []string, dest string) error
- func CopyFile(src, dst string) (int64, error)
- func Exists(path string) bool
- func IsCompressed(src string) bool
- func MD5sum(path string) (string, error)
- func RemoveAllContent(dir string) error
- func RenameFile(oldpath, newpath string) error
- func RunCmdWithOutput(cmd *exec.Cmd, outfile string) error
- type FileCompressor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArchiveFiles ¶
ArchiveFiles creates an archive for a list of source files. The archive format is determined by the destinations' file extension, e.g. zip, tar.
func CopyFile ¶
CopyFile copies a file. If destination is a dir, the original filename will be kept. See https://opensource.com/article/18/6/copying-files-go
func IsCompressed ¶
IsCompressed checks if a file is compressed, by its extension.
func RemoveAllContent ¶
RemoveAllContent removes all files and subdirs from a dir.
func RenameFile ¶
RenameFile will rename the source to target using os function.
Types ¶
type FileCompressor ¶
type FileCompressor struct { Src string // Source file, required. // Destination Dst can be empty, an existing directory or the explicit destination filename. // If it is empty or a directory, the destination filename will be built automatically. Dst string // Whether to overwrite existing files when creating files. OverwriteExisting bool // Whether the original file should be deleted after a successful de/compression. DeleteSource bool }
FileCompressor can compress and decompress single files. As mholt/archiver does not support Z-compressed files, we make our own FileCompressor.
func (*FileCompressor) Decompress ¶
func (fc *FileCompressor) Decompress() (string, error)
Decompress the file and return the filename of the decompressed file. It choses the right filetype by its extension.