mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add support for OFstream atomic file creation (#2631)
- with ATOMIC, an intermediary file is created - eg, (fileAbc~tmp~) where all of the output is written to. When the stream goes out of scope, this intermediary file is moved/renamed to the actually output name - eg, (fileAbc~tmp~) -> (fileAbc). This adds some safety if the simulation crashes while writing the file, since it will the partial (corrupt) file will be left behind as (fileAbc~tmp~) and not as (fileAbc), which means it will will be treated as a backup file and not loaded again on restart. ENH: provided enumeration for APPEND/NON_APPEND - clearer than using bool (with comments). Since append mode is primarily only used by masterOFstream etc this change is unlikely to affect user coding. ENH: use file atomic for ensight file creation - avoids corrupt (truncated) files being referenced by the ensight case file if the simulation crashes while writing the ensight file.
This commit is contained in:
@ -79,7 +79,7 @@ Foam::ensightFile::ensightFile
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
:
|
||||
OFstream(ensight::FileName(pathname), fmt)
|
||||
OFstream(IOstreamOption::ATOMIC, ensight::FileName(pathname), fmt)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@ -92,7 +92,7 @@ Foam::ensightFile::ensightFile
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
:
|
||||
OFstream(path/ensight::FileName(name), fmt)
|
||||
OFstream(IOstreamOption::ATOMIC, path/ensight::FileName(name), fmt)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user