tds3p-rsvp-reader/firmware/include/Library.h

31 lines
1.2 KiB
C++

#pragma once
#include <Arduino.h>
#include <vector>
class Library {
public:
bool loadLastOrFirst(String& path, String& contents) const;
bool load(const String& path, String& contents) const;
bool loadSidecar(const String& chapterPath, std::vector<uint8_t>& bytes) const;
bool selectBook(const String& currentPath, int direction, String& chapterPath) const;
bool selectChapter(const String& currentPath, int direction, String& chapterPath) const;
bool previousChapter(const String& currentPath, String& chapterPath) const;
bool nextChapter(const String& currentPath, String& chapterPath) const;
String bookName(const String& chapterPath) const;
String chapterName(const String& chapterPath) const;
private:
bool ensureBooks() const;
bool ensureChapters(const String& directoryPath) const;
bool firstChapter(const String& directoryPath, String& chapterPath) const;
bool loadFile(const String& path, String& contents) const;
bool firstBook(String& path) const;
mutable bool booksCached_ = false;
mutable std::vector<String> books_;
mutable String chapterDirectory_;
mutable std::vector<String> chapters_;
mutable std::vector<String> chapterTitles_;
};