![]() |
Bitcoin Core
28.1.0
P2P Digital Currency
|
Non-refcounted RAII wrapper for FILE*. More...
#include <streams.h>
Public Member Functions | |
| AutoFile (std::FILE *file, std::vector< std::byte > data_xor={}) | |
| ~AutoFile () | |
| AutoFile (const AutoFile &)=delete | |
| AutoFile & | operator= (const AutoFile &)=delete |
| bool | feof () const |
| int | fclose () |
| std::FILE * | release () |
| Get wrapped FILE* with transfer of ownership. More... | |
| bool | IsNull () const |
| Return true if the wrapped FILE* is nullptr, false otherwise. More... | |
| void | SetXor (std::vector< std::byte > data_xor) |
| Continue with a different XOR key. More... | |
| std::size_t | detail_fread (Span< std::byte > dst) |
| Implementation detail, only used internally. More... | |
| void | seek (int64_t offset, int origin) |
| int64_t | tell () |
| void | read (Span< std::byte > dst) |
| void | ignore (size_t nSize) |
| void | write (Span< const std::byte > src) |
| template<typename T > | |
| AutoFile & | operator<< (const T &obj) |
| template<typename T > | |
| AutoFile & | operator>> (T &&obj) |
| bool | Commit () |
| bool | IsError () |
| bool | Truncate (unsigned size) |
Protected Attributes | |
| std::FILE * | m_file |
| std::vector< std::byte > | m_xor |
| std::optional< int64_t > | m_position |
Non-refcounted RAII wrapper for FILE*.
Will automatically close the file when it goes out of scope if not null. If you're returning the file pointer, return file.release(). If you need to close the file early, use file.fclose() instead of fclose(file).
|
explicit |
Definition at line 11 of file streams.cpp.
|
inline |
|
delete |
| bool AutoFile::Commit | ( | ) |
| std::size_t AutoFile::detail_fread | ( | Span< std::byte > | dst | ) |
Implementation detail, only used internally.
Definition at line 20 of file streams.cpp.
|
inline |
|
inline |
| void AutoFile::ignore | ( | size_t | nSize | ) |
Definition at line 66 of file streams.cpp.
| bool AutoFile::IsError | ( | ) |
Definition at line 109 of file streams.cpp.
|
inline |
| void AutoFile::read | ( | Span< std::byte > | dst | ) |
|
inline |
| void AutoFile::seek | ( | int64_t | offset, |
| int | origin | ||
| ) |
Definition at line 32 of file streams.cpp.
|
inline |
| int64_t AutoFile::tell | ( | ) |
| bool AutoFile::Truncate | ( | unsigned | size | ) |
| void AutoFile::write | ( | Span< const std::byte > | src | ) |
1.8.14