fs

package
v0.19.6 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 18 Imported by: 10

Documentation

Overview

Package fs contains helper functions to deal with files and folders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsoluteFileExists

func AbsoluteFileExists(path string) (res bool)

AbsoluteFileExists checks if an absolute path is an existing fs.

func ApplyCommands added in v0.16.0

func ApplyCommands(cmds []*exec.Cmd, title string, verbose bool) error

ApplyCommands using goroutines. Can be applied to files.

func CalculateMD5First4KB

func CalculateMD5First4KB(path string) string

CalculateMD5First4KB calculates the MD5 of the beginning of a fs.

func CalculateSHA256

func CalculateSHA256(filename string) (string, error)

CalculateSHA256 calculates a fs's current hash

func CopyDir

func CopyDir(src, dst string, useHardLinks bool) error

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string, useHardLinks bool) (err error)

CopyFile copies a fs from src to dst. If src and dst files exist, and are the same, then return success. Copy the fs contents from src to dst.

func DeleteEmptyDirs

func DeleteEmptyDirs(root string) error

DeleteEmptyDirs recursively deletes empty folders in a given path.

func DirExists

func DirExists(path string) bool

DirExists checks if a directory exists.

func DirIsEmpty

func DirIsEmpty(path string) (bool, error)

DirIsEmpty checks if a directory is empty.

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile will download a url to a local file. It will write as it downloads and not load the whole file into memory.

func FileExists

func FileExists(path string) bool

FileExists checks if a path is valid

func FileSize

func FileSize(a uint64) string

func FileSizeDelta

func FileSizeDelta(a int64) string

func GetFilesByExt added in v0.3.0

func GetFilesByExt(directoryPath, extension string) ([]string, error)

GetFilesByExt returns all files found in a directory with a specific extension

func GetMaxPathLength added in v0.17.0

func GetMaxPathLength(dir string) int

GetMaxPathLength inside a directory, including the name of the directory itself.

func GetUniqueTimestampedFilename

func GetUniqueTimestampedFilename(dir, filename, extension string) (string, error)

GetUniqueTimestampedFilename for a given filename.

func MoveDir added in v0.5.0

func MoveDir(current, new string, doNothing, interactive bool) (bool, error)

MoveDir moves a directory to its new home.

func SanitizePath

func SanitizePath(path string) string

SanitizePath to have an acceptable path

func Sign added in v0.2.0

func Sign(a int64) string

Types

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
)

func (ByteSize) String

func (b ByteSize) String() string

Jump to

Keyboard shortcuts

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