|
ADS-IDAC Engine 5.0.0
|
#include <fstream>#include <iostream>#include <string>#include <vector>#include <cstdlib>Go to the source code of this file.
Functions | |
| bool | checked_close (std::ofstream &ofs, const std::string &path) |
| Flush and close an output stream and report a failed write. More... | |
| void | write_file_or_die (const std::string &path, const char *data, size_t size) |
| Write an entire buffer to a binary file (truncating it); fatal on any failure. More... | |
| bool | read_file_verified (const std::string &path, std::vector< char > &out) |
Read an entire binary file into out, verifying the byte count. More... | |
|
inline |
Flush and close an output stream and report a failed write.
Disk-full and quota errors on HPC filesystems otherwise leave truncated ZKPS/ZESNode/analysis files behind without any message. On failure the line "ERROR: write failed (disk full or I/O error): <path>" goes to stderr and is appended to "err messages.txt" in the working directory. The process is NOT terminated; acting on the result is up to the caller.
| ofs | Stream to flush and close (closed in every case). |
| path | File name used in the message only. |
Definition at line 19 of file CheckedIO.h.
Referenced by BranchEndState::saveInfoToFile().
|
inline |
Read an entire binary file into out, verifying the byte count.
| path | File to read. |
| out | Resized to the file size and overwritten. After a short read it keeps the full size with only the leading bytes valid; after an open failure it is left unchanged. |
out); false, after an "ERROR: ..." line on stderr, on open failure or short read. Definition at line 64 of file CheckedIO.h.
Referenced by build_serial_checkpoint(), Client::ensure_base_cache(), RelapSolver::restore(), Client::restore_relap_state(), and Client::Work().
|
inline |
Write an entire buffer to a binary file (truncating it); fatal on any failure.
A restart backup truncated under ENOSPC would surface much later as a RELAP5 abort when the corrupt blob is restored, so corrupt restart data is never survivable: on an open or write failure this prints "FATAL: failed to
write ..." on stderr and calls std::exit(1) (not MPI_Abort). A partial file may remain at path.
| path | Destination file. |
| data | Buffer to write. |
| size | Number of bytes in data. |
Definition at line 42 of file CheckedIO.h.
References PG::size.
Referenced by main(), and AdsidacCallback::onBranchingPoint().