fileutil

package
v0.0.0-...-a9e1be7 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMemoryAccess = errors.New("invalid memory access")

Functions

func CopyRegularFileByPath

func CopyRegularFileByPath(src, dst string) error

CopyRegularFileByPath copies a file from src to dst

func CopyRegularFileByRelativePath

func CopyRegularFileByRelativePath(srcName string, dstDir *os.File, dstName string) error

CopyRegularFileByRelativePath copies a file from src to dst, where destination is relative to a given directory. This function needs needed capabilities to be set before it is called.

func CreateAt

func CreateAt(dir *os.File, relativePath string) (*os.File, error)

CreateAt implements the same logic as os.Create using directory FD and relative path.

func Dup

func Dup(file *os.File) (*os.File, error)

Dup is a wrapper function to the `dup` syscall using golang types.

func IsDirEmpty

func IsDirEmpty(pathname string) (bool, error)

IsDirEmpty returns true if directory contains no files

func IsRegularFile

func IsRegularFile(name string) (bool, error)

IsRegularFile checks if the given file name points to a regular file

func MkdirAllAtExist

func MkdirAllAtExist(dir *os.File, relativePath string, perm fs.FileMode) error

MkdirAllAtExist recursively creates a directory and all necessary parents using mkdirat, ignoring EEXIST errors.

func MkdirAt

func MkdirAt(dir *os.File, relativePath string, perm fs.FileMode) error

MkdirAt is a wrapper function to the `mkdirat` syscall using golang types.

func MkdirAtExist

func MkdirAtExist(dir *os.File, relativePath string, perm fs.FileMode) error

MkdirAtExist is a wrapper function to the `mkdirat` syscall using golang types, ignoring EEXIST error.

func NewProtectedReader

func NewProtectedReader(data []byte) io.ReaderAt

NewProtectedReader returns an io.ReaderAt that wraps around a byte slice. Unlike the reader returned from bytes.NewReader(), this reader protects the reading function from fatal errors caused by invalid memory accesses to the underlying byte slice. If a fatal error occurs (e.g. SIGBUS or SIGSEGV), the read simply fails with an error that indicates a bad memory access. This is intended for reading from mmap'ed files, where a change to the file on disk can cause areas of the mapped memory to become invalid, resulting in a SIGBUS when accessing them.

func OpenAt

func OpenAt(dir *os.File, relativePath string, flags int, perm fs.FileMode) (*os.File, error)

OpenAt is a wrapper function to the `openat` syscall using golang types.

func OpenExistingDir

func OpenExistingDir(p string) (*os.File, error)

OpenExistingDir open a directory with given path, and return the os.File of it.

func RemoveAt

func RemoveAt(dir *os.File, relativePath string, flags int) error

RemoveAt is a wrapper function to the `unlinkat` syscall using golang types.

func RenameAt

func RenameAt(olddir *os.File, oldpath string, newdir *os.File, newpath string) error

RenameAt is a wrapper function to the `renameat` syscall using golang types.

Types

This section is empty.

Jump to

Keyboard shortcuts

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