25 static constexpr
char INDEX_MAGIC[8] =
"Scid.si";
33 Header.description[0] = 0;
34 std::memset(Header.customFlagDesc, 0,
sizeof(Header.customFlagDesc));
35 Header.dirty_ =
false;
62 std::string fname = filename;
87 std::string fname = filename;
90 if (FilePtr->
Open (fname.c_str(), fmode) !=
OK) {
97 FilePtr->sgetn(magic, 8);
98 if (!std::equal(std::begin(magic), std::end(magic), std::begin(INDEX_MAGIC),
99 std::end(INDEX_MAGIC))) {
123 if (Header.version >= 400) {
139 Index::WriteHeader ()
142 if (FilePtr->pubseekpos(0) != std::streampos(0))
return ERROR_FileWrite;
145 std::streamsize n = 0;
146 n += FilePtr->sputn(INDEX_MAGIC, 8);
156 Header.dirty_ =
false;
165 if (idx == Header.numGames) {
168 Header.dirty_ =
true;
173 if (FilePtr == NULL)
return OK;
175 if ((seqWrite_ == 0) || (idx != seqWrite_ + 1)) {
177 if (FilePtr->pubseekpos(pos) != pos) {
183 seqWrite_ = (res ==
OK) ? idx : 0;
const uint INDEX_HEADER_SIZE
const versionT SCID_OLDEST_VERSION
int WriteFourBytes(uint32_t value)
Writes a 32-bit unsigned integer.
const uint INDEX_ENTRY_SIZE
void resize(size_t count)
const errorT ERROR_BadMagic
const uint CUSTOM_FLAG_DESC_LENGTH
const errorT ERROR_FileWrite
const errorT ERROR_BadArg
const uint SCID_DESC_LENGTH
uint16_t ReadTwoBytes()
Reads a 16-bit unsigned integer.
int WriteThreeBytes(uint32_t value)
Writes a 24-bit unsigned integer.
int WriteTwoBytes(uint32_t value)
Writes a 16-bit unsigned integer.
uint32_t ReadThreeBytes()
Reads a 24-bit unsigned integer.
errorT flush()
flush() - writes all cached data to the file
errorT Open(const char *filename, fileModeT fmode)
Opens a file.
errorT Write(T *file, versionT version) const
const errorT ERROR_FileVersion
errorT Open(const char *filename, fileModeT fmode)
const char INDEX_SUFFIX[]
errorT Create(const char *filename)
errorT WriteEntry(const IndexEntry *ie, gamenumT idx)
WriteEntry() - modify a game in the Index.
Adds some helper functions to std::filebuf:
uint32_t ReadFourBytes()
Reads a 32-bit unsigned integer.
void push_back(const T &e)
const versionT SCID_VERSION
const errorT ERROR_FileMode
const uint CUSTOM_FLAG_MAX
const errorT ERROR_FileOpen