filesystem

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockFail    = errors.New("failed to acquire lock")
	ErrUnlockFail  = errors.New("failed to release lock")
	ErrLockIsNil   = errors.New("nil lock")
	ErrInvalidPath = errors.New("invalid path")
)

Functions

func AtomicWrite

func AtomicWrite(parent string, fileName string, perm os.FileMode, data []byte) error

func Lock

func Lock(path string) (file *os.File, err error)

Lock places an advisory write lock on the file, blocking until it can be locked.

If Lock returns nil, no other process will be able to place a read or write lock on the file until this process exits, closes f, or calls Unlock on it.

func ReadOnlyLock

func ReadOnlyLock(path string) (file *os.File, err error)

ReadOnlyLock places an advisory read lock on the file, blocking until it can be locked.

If ReadOnlyLock returns nil, no other process will be able to place a write lock on the file until this process exits, closes f, or calls Unlock on it.

func Unlock

func Unlock(lock *os.File) error

Unlock removes an advisory lock placed on f by this process.

func ValidatePathComponent

func ValidatePathComponent(pathComponent string) error

ValidatePathComponent will enforce os specific filename restrictions on a single path component.

func WithLock

func WithLock(path string, function func() error) (err error)

WithLock executes the provided function after placing a write lock on `path`. The lock is released once the function has been run, regardless of outcome.

func WithReadOnlyLock

func WithReadOnlyLock(path string, function func() error) (err error)

WithReadOnlyLock executes the provided function after placing a read lock on `path`. The lock is released once the function has been run, regardless of outcome.

Types

This section is empty.

Jump to

Keyboard shortcuts

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