simvx.core.io

Filesystem I/O helpers shared across the engine.

Centralises crash-safe write patterns so the IDE, scene save, asset writer, and other consumers share one implementation. The pickle-rotation flavour lives in simvx.core.save_manager.pickle_atomic for the (game save + editor autosave) payloads that need .bak/.bak2 chains.

Module Contents

Functions

atomic_write_text

Write text to path atomically.

API

simvx.core.io.atomic_write_text(path: pathlib.Path | str, text: str, *, encoding: str = 'utf-8') pathlib.Path[source]

Write text to path atomically.

Writes to <path>.tmp, fsyncs, then os.replace() onto the target so a crash mid-write never leaves a truncated file on disk – either the old file or the new one is fully present at every instant.

Creates parent directories as needed. Raises OSError on write failure (the temp file is best-effort cleaned).