Documentation
¶
Overview ¶
Package fsutil contains utilities for working with the file system.
Index ¶
- func ByteCountIEC[...](count T) stringdeprecated
- func FileExists(path string) (bool, error)
- func MustFileExists(path string) bool
- func MustReplaceTildeInDir(dir string) string
- func ReplaceTildeInDir(dir string) (string, error)
- func ReportedClose(closer io.Closer, name string, reportErrPtr *error)
- func ValidateChecksum(path, checkHash string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteCountIEC
deprecated
func ByteCountIEC[T ~int64 | ~uint64 | ~int | ~uint | ~int32 | ~uint32 | ~int16 | ~uint16 | ~int8 | ~uint8 | ~uintptr]( count T) string
ByteCountIEC converts a byte count to string using the appropriate unit (B, Kb, MiB, GiB, ...). It uses the binary prefix system from IEC -- so powers of 1024 (as opposed to powers 1000).
Deprecated: use humanize.Bytes() instead.
func FileExists ¶
FileExists returns whether the file or directory exists or an error if something went wrong in the filesystem.
func MustFileExists ¶
MustFileExists returns whether the file or directory exists. It panics on file system errors.
func MustReplaceTildeInDir ¶
MustReplaceTildeInDir by the user's home directory. Returns dir if it doesn't start with "~".
It may panic with an error if `dir` has an unknown user (e.g: `~unknown/...`)
func ReplaceTildeInDir ¶
ReplaceTildeInDir by the user's home directory. Returns dir if it doesn't start with "~".
It returns an error if `dir` has an unknown user or some other filesystem error (e.g: `~unknown/...`)
func ReportedClose ¶
ReportedClose closes the closer object (a file?) and reports in case of error.
It reports by setting reportErrPtr if it's set and not in use yet. Otherwise, it logs the error and continues.
Use this in a defer statement.
func ValidateChecksum ¶
ValidateChecksum verifies that the checksum of the file in the given path matches the checksum given. If it fails, it will remove the file (!) and return and error. If checkHash is empty, this is a no-op.
Types ¶
This section is empty.