35 lines
978 B
C++
35 lines
978 B
C++
#include "BookCacheUtils.h"
|
|
|
|
#include <Epub.h>
|
|
#include <FsHelpers.h>
|
|
#include <Logging.h>
|
|
#include <Txt.h>
|
|
#include <Xtc.h>
|
|
|
|
bool isBookCacheDirectoryName(const char* name) {
|
|
if (!name) {
|
|
return false;
|
|
}
|
|
|
|
constexpr char EPUB_PREFIX[] = "epub_";
|
|
constexpr char TXT_PREFIX[] = "txt_";
|
|
constexpr char XTC_PREFIX[] = "xtc_";
|
|
|
|
return strncmp(name, EPUB_PREFIX, std::size(EPUB_PREFIX) - 1) == 0 ||
|
|
strncmp(name, TXT_PREFIX, std::size(TXT_PREFIX) - 1) == 0 ||
|
|
strncmp(name, XTC_PREFIX, std::size(XTC_PREFIX) - 1) == 0;
|
|
}
|
|
|
|
void clearBookCache(const std::string& path) {
|
|
if (FsHelpers::hasEpubExtension(path)) {
|
|
Epub(path, "/.crosspoint").clearCache();
|
|
} else if (FsHelpers::hasXtcExtension(path)) {
|
|
Xtc(path, "/.crosspoint").clearCache();
|
|
} else if (FsHelpers::hasTxtExtension(path)) {
|
|
Txt(path, "/.crosspoint").clearCache();
|
|
} else {
|
|
return;
|
|
}
|
|
LOG_DBG("BookCache", "Done checking metadata cache for: %s", path.c_str());
|
|
}
|