fileutils

package
v0.0.0-...-55114bd Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fileutils contains utilities and helpers to manage and manipulate files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFileDigest

func CheckFileDigest(path string, digest string) bool

CheckFileDigest will compare input digest to the checksum of input file. Returns whether the input digest is equal to the input file's one.

func DiscUsageMegaBytes

func DiscUsageMegaBytes(path string) (string, error)

DiscUsageMegaBytes returns disk usage for input path in MB (rounded).

func Exist

func Exist(path string) bool

Exist returns if a path exists or not.

func GetFileDigest

func GetFileDigest(path string) string

GetFileDigest will return the sha256sum of input file. Empty if error occurs.

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile will return the content of input file or error. This is a linux-only implementation using syscalls for performance benefits.

func UntarFile

func UntarFile(path string, target string) error

UntarFile will untar target file to target directory. If userns is specified and it is keep-id, it will perform the untarring in a new user namespace with user id maps set, in order to prevent permission errors.

func WriteFile

func WriteFile(path string, content []byte, perm uint32) error

WriteFile will write the content in input to file in path or error. This is a linux-only implementation using syscalls for performance benefits.

Types

This section is empty.

Jump to

Keyboard shortcuts

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