safefile

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenFile

func OpenFile(rootDir, name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile opens a file within rootDir with given flags using os.Root. The returned *os.File is independent and safe to use after this function returns.

func ReadFile

func ReadFile(rootDir, name string) ([]byte, error)

ReadFile reads a file within rootDir using os.Root to prevent directory traversal. The name must be a relative path within rootDir.

func Stat

func Stat(rootDir, name string) (os.FileInfo, error)

Stat returns FileInfo for a file scoped within rootDir using os.Root.

func WriteFile

func WriteFile(rootDir, name string, data []byte, perm os.FileMode) error

WriteFile writes data to a file within rootDir using os.Root to prevent directory traversal. The file is created or truncated with the given permissions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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