fileutil

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSymlinkTarget = errors.New("refusing to replace a symlink target")
)

Functions

func AtomicReplaceFile

func AtomicReplaceFile(tempPath, targetPath string) error

AtomicReplaceFile atomically replaces targetPath with tempPath. tempPath and targetPath must be on the same filesystem.

func AtomicReplaceFileNoSymlink(tempPath, targetPath string) error

AtomicReplaceFileNoSymlink atomically replaces targetPath, but refuses a symlink that was present when the commit was attempted. The check is paired with rename: rename never follows the final target symlink, so a race cannot redirect the staged bytes outside targetPath.

func AtomicWriteNewFile added in v0.23.1

func AtomicWriteNewFile(tempPath, targetPath string) error

AtomicWriteNewFile atomically installs tempPath at targetPath only if targetPath does not already exist. tempPath and targetPath must be on the same filesystem.

func SyncDir added in v0.28.0

func SyncDir(path string) error

SyncDir flushes directory metadata when the platform supports opening a directory for synchronization. Callers may treat failures as best effort.

Types

type CommittedError added in v0.28.0

type CommittedError struct {
	Err error
}

CommittedError reports a cleanup error after the destination was already installed. Callers must not report the operation as an uncommitted write.

func (*CommittedError) Error added in v0.28.0

func (e *CommittedError) Error() string

func (*CommittedError) Unwrap added in v0.28.0

func (e *CommittedError) Unwrap() error

Jump to

Keyboard shortcuts

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