Changeset View
Changeset View
Standalone View
Standalone View
src/flatfile.h
Show All 17 Lines | struct FlatFilePos { | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(VARINT(nFile)); | READWRITE(VARINT(nFile)); | ||||
READWRITE(VARINT(nPos)); | READWRITE(VARINT(nPos)); | ||||
} | } | ||||
FlatFilePos() { SetNull(); } | FlatFilePos() : nFile(-1), nPos(0) {} | ||||
FlatFilePos(int nFileIn, unsigned int nPosIn) { | FlatFilePos(int nFileIn, unsigned int nPosIn) | ||||
nFile = nFileIn; | : nFile(nFileIn), nPos(nPosIn) {} | ||||
nPos = nPosIn; | |||||
} | |||||
friend bool operator==(const FlatFilePos &a, const FlatFilePos &b) { | friend bool operator==(const FlatFilePos &a, const FlatFilePos &b) { | ||||
return (a.nFile == b.nFile && a.nPos == b.nPos); | return (a.nFile == b.nFile && a.nPos == b.nPos); | ||||
} | } | ||||
friend bool operator!=(const FlatFilePos &a, const FlatFilePos &b) { | friend bool operator!=(const FlatFilePos &a, const FlatFilePos &b) { | ||||
return !(a == b); | return !(a == b); | ||||
} | } | ||||
Show All 27 Lines | public: | ||||
* amount. | * amount. | ||||
*/ | */ | ||||
FlatFileSeq(fs::path dir, const char *prefix, size_t chunk_size); | FlatFileSeq(fs::path dir, const char *prefix, size_t chunk_size); | ||||
/** Get the name of the file at the given position. */ | /** Get the name of the file at the given position. */ | ||||
fs::path FileName(const FlatFilePos &pos) const; | fs::path FileName(const FlatFilePos &pos) const; | ||||
/** Open a handle to the file at the given position. */ | /** Open a handle to the file at the given position. */ | ||||
FILE *Open(const FlatFilePos &pos, bool fReadOnly = false); | FILE *Open(const FlatFilePos &pos, bool read_only = false); | ||||
/** | /** | ||||
* Allocate additional space in a file after the given starting position. | * Allocate additional space in a file after the given starting position. | ||||
* The amount allocated will be the minimum multiple of the sequence chunk | * The amount allocated will be the minimum multiple of the sequence chunk | ||||
* size greater than add_size. | * size greater than add_size. | ||||
* | * | ||||
* @param[in] pos The starting position that bytes will be allocated after. | * @param[in] pos The starting position that bytes will be allocated after. | ||||
* @param[in] add_size The minimum number of bytes to be allocated. | * @param[in] add_size The minimum number of bytes to be allocated. | ||||
Show All 19 Lines |