mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
4776bd7639
file.write() streamed directly onto the target path, so a crash mid-write left a truncated file with dangling STEP references. Serialize to a temp file in the same directory, then atomically rename it onto the target. - New IfcUtil::path::atomic_rename_file: std::rename on POSIX, MoveFileExW with MOVEFILE_REPLACE_EXISTING on Windows. Unlike rename_file it never unlinks the destination first, so there is no window where it goes missing. - Fully in C++/swig (per aothms), so the FILE_NAME header is untouched: it comes from the model header, not the output path (verified empirically). - Temp lives next to the target so the rename stays on one filesystem. - Stream is closed before the rename (Windows cannot move an open file). - On any write error the temp is removed and the original target is intact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>