![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Own a staging stream and publish it by a checked single-file rename. More...
#include <AtomicOutputFile.hpp>
Public Member Functions | |
| AtomicOutputFile (const std::filesystem::path &destination, bool binary=false) | |
| Create an exclusive staging sibling for a single output destination. | |
| ~AtomicOutputFile () | |
| Close any open staging stream and best-effort discard unpublished output. | |
| AtomicOutputFile (const AtomicOutputFile &)=delete | |
| Disallow copying ownership of the staging stream and publication state. | |
| AtomicOutputFile & | operator= (const AtomicOutputFile &)=delete |
| Disallow copy replacement of a pending file publication. | |
| FILE * | stream () const |
| Borrow the writable staging stream. | |
| const std::string & | error () const |
| Borrow the latest stored file-operation diagnostic. | |
| bool | commit () |
| Flush, sync, close and attempt to rename staging over the destination. | |
Own a staging stream and publish it by a checked single-file rename.
Noncopyable; destroys unpublished staging on scope exit. Caller writes synchronously through stream(), then calls commit() and inspects error() on failure. No internal thread synchronization; retain the object until serialization completes.
|
inlineexplicit |
Create an exclusive staging sibling for a single output destination.
Refuses an existing nonregular destination or one without any write permission bits, then tries up to 32 unique staging names and copies existing permissions. Filesystem/refusal diagnostics are stored rather than thrown; allocation/path-conversion exceptions may still propagate. Check stream() before serializing. Does not create missing parent directories.
| [in] | destination | Borrowed native path copied into the object; existing symlinks resolve to their target, dangling symlinks are refused. |
| [in] | binary | True uses binary-exclusive mode; false permits platform text newline translation. |
|
inline |
Close any open staging stream and best-effort discard unpublished output.
Does not commit. Remove/close errors are ignored; a failed cleanup may leave the staging file. Published destination is retained.
|
delete |
Disallow copying ownership of the staging stream and publication state.
|
inline |
Flush, sync, close and attempt to rename staging over the destination.
Checks ferror, fflush, platform file sync and fclose in order, closes even on failure, then uses filesystem::rename. On failure error() describes the first relevant stage and unpublished staging remains for destructor cleanup. After any attempt the stream is unavailable; a second commit returns false. This is one-file rename publication, not a multi-file transaction or parent-directory durability guarantee.
|
inline |
Borrow the latest stored file-operation diagnostic.
|
delete |
Disallow copy replacement of a pending file publication.
|
inline |
Borrow the writable staging stream.
Caller writes but must not fclose() or retain it past commit/destruction; ownership stays with this object. Caller serializes all access.