fileutils

package
v0.0.0-...-6b70eb7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveFiles

func ArchiveFiles(sources []string, dest string) error

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

func CopyFile(src, dst string) (int64, error)

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 Exists

func Exists(path string) bool

Exists returns true if the file or directory exists, otherwise false.

func IsCompressed

func IsCompressed(src string) bool

IsCompressed checks if a file is compressed, by its extension.

func MD5sum

func MD5sum(path string) (string, error)

MD5sum returns the computed MD5 checksum for the given file.

func RemoveAllContent

func RemoveAllContent(dir string) error

RemoveAllContent removes all files and subdirs from a dir.

func RenameFile

func RenameFile(oldpath, newpath string) error

RenameFile will rename the source to target using os function.

func RunCmdWithOutput

func RunCmdWithOutput(cmd *exec.Cmd, outfile string) error

RunCmdWithOutput runs the specified command and writes its output to the given file.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL