fileutils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 13 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 CopyFileContainer

func CopyFileContainer(src string, dest string) error

CopyFileContainer will copy file from src to dest.

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 Mount

func Mount(src, dest string, mode uintptr) error

Mount will bind-mount src to dest, using input mode.

func MountBind

func MountBind(src, dest string) error

MountBind will bind-mount src path in dest path. Said mount will be created with mode: rbind,rprivate.

func MountBindRO

func MountBindRO(src, dest string) error

MountBindRO will bind-mount read-only src path in dest path. Said mount will be created with mode: rbind,rprivate,ro,nosuid,noexec,nodev.

func MountCgroup

func MountCgroup(dest string) error

MountCgroup will mount a new cgroup/cgroup2 fs on dest.

func MountDevPts

func MountDevPts(dest string) error

MountDevPts will mount a new devpts in dest path. Said mount will be created with mode: noexec,nosuid,newinstance,ptmxmode=0666,mode=0620.

func MountMqueue

func MountMqueue(dest string) error

MountMqueue will mount a new mqueue tmpfs in dest path. Said mount will be created with mode: noexec,nosuid,nodev.

func MountProc

func MountProc(dest string) error

MountProc will mount a new procfs in dest path. Said mount will be created with mode: noexec,nosuid,nodev.

func MountShm

func MountShm(dest string) error

MountShm will mount a new shm tmpfs to dest path. Said mount will be created with mode: noexec,nosuid,nodev,mode=1777,size=65536k.

func MountTmpfs

func MountTmpfs(dest string) error

MountTmpfs will mount a new tmpfs in dest path.

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 Umount

func Umount(dest string) error

Umount will force umount a destination path.

func UntarFile

func UntarFile(path string, target string, userns 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