Documentation
¶
Overview ¶
Package file provides atomic file write utilities and platform-specific optimizations. Atomic writes ensure that files are either fully written or not modified, preventing corruption from partial writes or concurrent access. Large files are marked as not needed to optimize page cache behavior on Linux systems.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicWrite ¶
AtomicWrite writes data atomically to a file with the specified permissions. It uses a temporary file in the same directory and atomically renames it to the target path.
func AtomicWriteReader ¶
AtomicWriteReader writes data from a reader atomically to a file with the specified permissions. It uses a temporary file and atomically renames it, marking large files as not needed for cache optimization.
func Exists ¶
Exists checks if a file or directory exists at the given path. It returns false only if the file does not exist; other errors (such as permission denied) return true.
func WriteFileAtomic ¶
WriteFileAtomic writes data to a file atomically using a temporary file and rename. It ensures that the file is either fully written with the new data or left unchanged. Data is flushed to disk before the rename operation to ensure durability.
Types ¶
This section is empty.