More review changes
This commit is contained in:
@@ -267,18 +267,25 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EPUB 3 collection metadata:
|
// EPUB 3 collection metadata:
|
||||||
// <meta property="belongs-to-collection">Series Name</meta>
|
// <meta property="belongs-to-collection">Series Name</meta> (character data)
|
||||||
|
// <meta property="belongs-to-collection" content="Series Name"/> (attribute, some generators)
|
||||||
// <meta property="group-position">1</meta>
|
// <meta property="group-position">1</meta>
|
||||||
if (metaProperty) {
|
if (metaProperty) {
|
||||||
if (strcmp(metaProperty, "belongs-to-collection") == 0 && self->series.empty()) {
|
if (strcmp(metaProperty, "belongs-to-collection") == 0 && self->series.empty()) {
|
||||||
self->series.clear();
|
if (metaContent) {
|
||||||
self->state = IN_BOOK_SERIES;
|
self->series = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH);
|
||||||
return;
|
} else {
|
||||||
|
self->state = IN_BOOK_SERIES;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (strcmp(metaProperty, "group-position") == 0 && self->seriesIndex.empty()) {
|
if (strcmp(metaProperty, "group-position") == 0 && self->seriesIndex.empty()) {
|
||||||
self->seriesIndex.clear();
|
if (metaContent) {
|
||||||
self->state = IN_BOOK_SERIES_INDEX;
|
self->seriesIndex = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH);
|
||||||
return;
|
} else {
|
||||||
|
self->state = IN_BOOK_SERIES_INDEX;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ constexpr uint32_t MAX_STRING_LENGTH = 4096;
|
|||||||
static bool readString(std::istream& is, std::string& s) {
|
static bool readString(std::istream& is, std::string& s) {
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
readPod(is, len);
|
readPod(is, len);
|
||||||
if (len > MAX_STRING_LENGTH) return false;
|
if (len > MAX_STRING_LENGTH) {
|
||||||
|
is.seekg(len, std::ios::cur); // skip payload to keep stream aligned
|
||||||
|
return false;
|
||||||
|
}
|
||||||
s.resize(len);
|
s.resize(len);
|
||||||
is.read(&s[0], len);
|
is.read(&s[0], len);
|
||||||
return true;
|
return true;
|
||||||
@@ -50,7 +53,10 @@ static bool readString(std::istream& is, std::string& s) {
|
|||||||
static bool readString(FsFile& file, std::string& s) {
|
static bool readString(FsFile& file, std::string& s) {
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
readPod(file, len);
|
readPod(file, len);
|
||||||
if (len > MAX_STRING_LENGTH) return false;
|
if (len > MAX_STRING_LENGTH) {
|
||||||
|
file.seekCur(len); // skip payload to keep file position aligned
|
||||||
|
return false;
|
||||||
|
}
|
||||||
s.resize(len);
|
s.resize(len);
|
||||||
file.read(reinterpret_cast<uint8_t*>(&s[0]), len);
|
file.read(reinterpret_cast<uint8_t*>(&s[0]), len);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ bool RecentBooksStore::loadFromBinaryFile() {
|
|||||||
// Old version, just read paths
|
// Old version, just read paths
|
||||||
uint8_t count;
|
uint8_t count;
|
||||||
serialization::readPod(inputFile, count);
|
serialization::readPod(inputFile, count);
|
||||||
recentBooks.clear();
|
std::vector<RecentBook> tmpRecentBooks;
|
||||||
recentBooks.reserve(count);
|
tmpRecentBooks.reserve(count);
|
||||||
for (uint8_t i = 0; i < count; i++) {
|
for (uint8_t i = 0; i < count; i++) {
|
||||||
std::string path;
|
std::string path;
|
||||||
if (!serialization::readString(inputFile, path)) {
|
if (!serialization::readString(inputFile, path)) {
|
||||||
@@ -142,17 +142,18 @@ bool RecentBooksStore::loadFromBinaryFile() {
|
|||||||
inputFile.close();
|
inputFile.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
recentBooks.push_back({path, title, author, "", ""});
|
tmpRecentBooks.push_back({path, title, author, "", ""});
|
||||||
} else {
|
} else {
|
||||||
recentBooks.push_back(book);
|
tmpRecentBooks.push_back(book);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
recentBooks = std::move(tmpRecentBooks);
|
||||||
} else if (version == 3) {
|
} else if (version == 3) {
|
||||||
uint8_t count;
|
uint8_t count;
|
||||||
serialization::readPod(inputFile, count);
|
serialization::readPod(inputFile, count);
|
||||||
|
|
||||||
recentBooks.clear();
|
std::vector<RecentBook> tmpRecentBooks;
|
||||||
recentBooks.reserve(count);
|
tmpRecentBooks.reserve(count);
|
||||||
uint8_t omitted = 0;
|
uint8_t omitted = 0;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < count; i++) {
|
for (uint8_t i = 0; i < count; i++) {
|
||||||
@@ -170,8 +171,9 @@ bool RecentBooksStore::loadFromBinaryFile() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
recentBooks.push_back({path, title, author, "", coverBmpPath});
|
tmpRecentBooks.push_back({path, title, author, "", coverBmpPath});
|
||||||
}
|
}
|
||||||
|
recentBooks = std::move(tmpRecentBooks);
|
||||||
|
|
||||||
if (omitted > 0) {
|
if (omitted > 0) {
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user