Documentation ¶
Index ¶
- Constants
- func ContentTypeForFileName(name string) string
- func CopyDir(src string, dst string, force bool) (err error)
- func CopyDirOverwrite(src string, dst string) (err error)
- func CopyDirPreserve(src string, dst string) error
- func CopyFile(src, dst string) (err error)
- func CopyFileOrDir(src string, dst string, force bool) (err error)
- func CreateUniqueDirectory(dir string, name string, maximumAttempts int) (string, error)
- func DeleteDirContents(dir string) error
- func DeleteDirContentsExcept(dir string, exceptDir string) error
- func DeleteFile(fileName string) (err error)
- func DestroyFile(filename string) error
- func DirExists(path string) (bool, error)
- func FileExists(path string) (bool, error)
- func FileIsEmpty(path string) (bool, error)
- func FilterFileExists(paths []string) []string
- func FirstFileExists(paths ...string) (string, error)
- func GlobAllFiles(basedir string, pattern string, fn func(string) error) error
- func IgnoreFile(path string, ignores []string) (bool, error)
- func IsEmpty(name string) (bool, error)
- func ListDirectory(root string, recurse bool) error
- func LoadBytes(dir, name string) ([]byte, error)
- func RecreateDirs(dirs ...string) error
- func RecreateSymLink(src, target string) error
- func RenameDir(src string, dst string, force bool) (err error)
- func RenameFile(src string, dst string) (err error)
- func ToValidFileSystemName(name string) string
- func UnTarFile(header *tar.Header, target string, tarReader io.Reader) error
- func UnTargz(tarball, target string, onlyFiles []string) error
- func UnTargzAll(tarball, target string) error
- func Unzip(src, dest string) error
- func UnzipSpecificFiles(src, dest string, onlyFiles ...string) error
- type IOFileHandles
Constants ¶
const ( // DefaultDirWritePermissions default permissions when creating a directory DefaultDirWritePermissions = 0760 // DefaultFileWritePermissions default permissions when creating a file DefaultFileWritePermissions = 0644 MaximumNewDirectoryAttempts = 1000 )
Variables ¶
This section is empty.
Functions ¶
func ContentTypeForFileName ¶
ContentTypeForFileName returns the MIME type for the given file name
func CopyDirOverwrite ¶
CopyDirOverwrite copies from the source dir to the destination dir overwriting files along the way
func CopyDirPreserve ¶
CopyDirPreserve copies from the src dir to the dst dir if the file does NOT already exist in dst
func CopyFileOrDir ¶
CopyFileOrDir copies the source file or directory to the given destination
func CreateUniqueDirectory ¶
CreateUniqueDirectory creates a new directory but if the combination of dir and name exists then append a number until a unique name is found
func DeleteDirContents ¶
DeleteDirContents removes all the contents of the given directory
func DeleteDirContentsExcept ¶
func DeleteFile ¶
DeleteFile deletes a file from the operating system. This should NOT be used to delete any sensitive information because it can easily be recovered. Use DestroyFile to delete sensitive information
func DestroyFile ¶
DestroyFile will securely delete a file by first overwriting it with random bytes, then deleting it. This should always be used for deleting sensitive information
func FileExists ¶
FileExists checks if path exists and is a file
func FileIsEmpty ¶
FileIsEmpty checks if a file is empty
func FilterFileExists ¶
FilterFileExists filters out files which do not exist
func FirstFileExists ¶
FirstFileExists returns the first file which exists or an error if we can't detect if a file that exists
func GlobAllFiles ¶
GlobAllFiles performs a glob on the pattern and then processes all the files found. if a folder matches the glob its treated as another glob to recurse into the directory
func IgnoreFile ¶
IgnoreFile returns true if the path matches any of the ignores. The match is the same as filepath.Match.
func ListDirectory ¶
ListDirectory logs the directory at path
func RecreateDirs ¶
DeleteDirContents removes all the contents of the given directory
func RecreateSymLink ¶ added in v1.0.46
RecreateSymLink removes any old symlink/binary if they exist and creates a new symlink from the given source
func RenameFile ¶
func ToValidFileSystemName ¶
ToValidFileSystemName converts the name to one that can safely be used on the filesystem
func UnTargz ¶
untargz a tarball to a target, from http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzipf
func UnTargzAll ¶
untargz a tarball to a target including any folders inside the tarball http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzipf
func Unzip ¶
Unzips the archvie into the specified directory returns an error if a general issue occurred unzipping the archive
func UnzipSpecificFiles ¶
Unzips the specified files from the archive returns an error if any of the specified files are not found or a general issue occurred unzipping the archive
Types ¶
type IOFileHandles ¶
type IOFileHandles struct { Err io.Writer In terminal.FileReader Out terminal.FileWriter }
IOFileHandles is a struct for holding CommonOptions' In, Out, and Err I/O handles, to simplify function calls.
func GetIOFileHandles ¶
func GetIOFileHandles(h *IOFileHandles) IOFileHandles
GetIOFileHandles lazily creates a file handles object if the input is nil