Expand description
Shared utility functions for file operations.
Structs§
- Atomic
Output File - Crash-safe output writing: content goes to a hidden temporary file next
to
final_path, andAtomicOutputFile::commitfsyncs it and renames it into place. Until then the final path holds whatever the caller put there (typically an empty placeholder claiming the name), so a crash or error never leaves a truncated file that looks complete. Dropping without committing removes the temporary file.
Functions§
- read_
n_ bytes_ from_ file - read_
up_ to - Reads from
readeruntilbufis full or EOF; returns the bytes read. Unlike a barereadcall this only returns short on EOF, which the streaming loops rely on to spot the final chunk. - resolve_
output_ dir - Resolves the output directory for a workflow: the given path (created if missing) or the current directory.
- sanitize_
relative_ path - Sanitizes a ‘/’-separated path from decrypted metadata into a relative
path that cannot escape the output directory: rejects
..components, backslashes, and (on Windows) drive prefixes and:stream separators, drops empty and.components (which also relativizes absolute paths). The decrypted name is deliberately not echoed into error messages.