fsutil

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fsutil provides filesystem utilities for atomic operations and syncing.

Index

Constants

This section is empty.

Variables

View Source
var ErrRenameNoReplaceUnsupported = errors.New("atomic rename no-replace unsupported")

ErrRenameNoReplaceUnsupported reports that the current platform does not provide an atomic no-replace rename primitive.

Functions

func AtomicWrite

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

AtomicWrite writes data to a temporary file, fsyncs, then renames to target path.

func FsyncDir

func FsyncDir(dirPath string) error

FsyncDir fsyncs a directory to ensure rename visibility is durable.

func FsyncTree

func FsyncTree(root string) error

FsyncTree recursively fsyncs all files under the given root directory. This ensures all data is durably written to disk before marking an operation complete.

func IsCommitUncertain

func IsCommitUncertain(err error) bool

IsCommitUncertain reports whether err means the filesystem mutation may have committed even though a later durability/sync step failed.

func RenameAndSync

func RenameAndSync(oldpath, newpath string) error

RenameAndSync renames old to new and fsyncs the parent directory.

func RenameNoReplaceAndSync

func RenameNoReplaceAndSync(oldpath, newpath string) error

RenameNoReplaceAndSync renames old to new without replacing an existing destination and fsyncs the parent directory.

Types

type CommitUncertainError

type CommitUncertainError struct {
	Op   string
	Path string
	Err  error
}

CommitUncertainError reports that an operation reached the point where its filesystem mutation may be visible, but a post-commit durability step failed.

func (*CommitUncertainError) Error

func (e *CommitUncertainError) Error() string

func (*CommitUncertainError) Unwrap

func (e *CommitUncertainError) Unwrap() error

Jump to

Keyboard shortcuts

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