fsutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fsutil provides small filesystem helpers shared across packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSharingOrLockViolation

func IsSharingOrLockViolation(err error) bool

IsSharingOrLockViolation reports whether err is a Windows sharing or lock violation: another open handle on the file denies the requested access. It is always false on other platforms, where the same errno values mean unrelated errors.

func RenameWithRetry

func RenameWithRetry(src, dst string, rename func(src, dst string) error) error

RenameWithRetry renames src to dst, retrying briefly on Windows when the destination is transiently locked (antivirus scanners, search indexers, or a concurrent reader holding the file open). rename overrides os.Rename so tests can exercise the retry path; pass nil to use os.Rename.

func ReplaceWithRetry

func ReplaceWithRetry(src, dst string, replace func(src, dst string) error) error

ReplaceWithRetry publishes src over dst using the platform's replacement primitive, retrying on the same transient Windows lock errors RenameWithRetry handles. On Windows it uses ReplaceFileW so an existing destination keeps its DACL and selected metadata instead of receiving the temporary file's inherited DACL. ReplaceFileW is not observer-atomic and may briefly leave dst absent; callers that cannot tolerate that must synchronize their own readers. On Unix replacement uses os.Rename.

replace overrides the platform primitive so tests can exercise the retry path; pass nil for the default.

Types

type CommittedReplacementCleanupError

type CommittedReplacementCleanupError struct {
	BackupPath string
	Cause      error
}

CommittedReplacementCleanupError reports that a replacement was committed, but the old destination retained at BackupPath could not be removed. Callers must treat the replacement itself as successful and surface the cleanup problem separately.

func (*CommittedReplacementCleanupError) Error

func (*CommittedReplacementCleanupError) Unwrap

Jump to

Keyboard shortcuts

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