MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ~AutoFile

Method ~AutoFile

src/streams.h:405–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403 explicit AutoFile(std::FILE* file, const Obfuscation& obfuscation = {});
404
405 ~AutoFile()
406 {
407 if (m_was_written) {
408 // Callers that wrote to the file must have closed it explicitly
409 // with the fclose() method and checked that the close succeeded.
410 // This is because here in the destructor we have no way to signal
411 // errors from fclose() which, after write, could mean the file is
412 // corrupted and must be handled properly at the call site.
413 // Destructors in C++ cannot signal an error to the callers because
414 // they do not return a value and are not allowed to throw exceptions.
415 Assume(IsNull());
416 }
417
418 if (fclose() != 0) {
419 LogError("Failed to close file: %s", SysErrorString(errno));
420 }
421 }
422
423 // Disallow copies
424 AutoFile(const AutoFile&) = delete;

Callers

nothing calls this directly

Calls 1

SysErrorStringFunction · 0.85

Tested by

no test coverage detected