fileutils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

IEC Sizes. kibis of bits

View Source
const (
	IByte = 1
	KByte = IByte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
)

SI Sizes.

Variables

This section is empty.

Functions

func Bytes

func Bytes(s uint64) string

Bytes produces a human readable representation of an SI size.

See also: ParseBytes.

Bytes(82854982) -> 83 MB

func CalculateSHA256Checksum

func CalculateSHA256Checksum(filePath string) (string, error)

func CheckFullPath added in v0.1.0

func CheckFullPath(path string) bool

func CheckLinuxPath added in v0.1.0

func CheckLinuxPath(path string) bool

func CheckWindowsPath added in v0.1.0

func CheckWindowsPath(path string) bool

func ChmodR

func ChmodR(path string, filePerm, dirPerm os.FileMode) error

ChmodR - Recursively chmod

func CopyFile

func CopyFile(src string, dst string) error

CopyFile - Copy a file from src to dst

func DeflateBuf

func DeflateBuf(data []byte) []byte

DeflateBuf - Deflate a buffer using BestCompression (9)

func Exist

func Exist(filePath string) bool

Exist - Check if a file exists

func ExtractTarGz

func ExtractTarGz(gzipPath string, dest string) error

ExtractTarGz extracts a .tar.gz file to the specified destination directory

func ForceRemoveAll

func ForceRemoveAll(rootPath string) error

func FormatWindowPath

func FormatWindowPath(path string) string

func GetExtensionByBytes added in v0.1.1

func GetExtensionByBytes(data []byte) (string, error)

func GetExtensionByPath added in v0.1.1

func GetExtensionByPath(filepath string) (string, error)

func IBytes

func IBytes(s uint64) string

IBytes produces a human readable representation of an IEC size.

See also: ParseBytes.

IBytes(82854982) -> 79 MiB

func MoveDirectory

func MoveDirectory(sourceDir, destDir string) error

func MoveFile

func MoveFile(sourcePath, destPath string) error

func ParseBytes

func ParseBytes(s string) (uint64, error)

ParseBytes parses a string representation of bytes into the number of bytes it represents.

See Also: Bytes, IBytes.

ParseBytes("42 MB") -> 42000000, nil ParseBytes("42 mib") -> 44040192, nil

func ReadFileFromTarGz

func ReadFileFromTarGz(tarGzFile string, tarPath string) ([]byte, error)

ReadFileFromTarGz - Read a file from a tar.gz file in-memory

func RemoveFile

func RemoveFile(filePath string) error

RemoveFile - Remove a file from src to dst

func ResolvePath

func ResolvePath(in string) string

ResolvePath - Resolve a path from an assumed root path

func UnzipOneWithBytes added in v0.1.0

func UnzipOneWithBytes(content []byte) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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