Something went wrong. Try again.
A fork of https://github.com/crosspoint-reader/crosspoint-reader
Something went wrong. Try again.
807 B · 23 lines
C++
123456789101112131415161718192021222324#include "OpdsFilename.h"
#include "StringUtils.h"
std::string opdsBookFilename(const std::string& author, const std::string& title, OpdsFilenameFormat format) { std::string base; switch (format) { case OpdsFilenameFormat::TitleAuthor: base = author.empty() ? title : title + " - " + author; break; case OpdsFilenameFormat::TitleOnly: base = title; break; case OpdsFilenameFormat::AuthorTitle: default: base = author.empty() ? title : author + " - " + title; break; } // sanitizeFilename caps at 100 bytes and never returns empty (falls back to // "book"); ".epub" is appended after so the extension is never truncated — // identical treatment to the previous inline construction. return StringUtils::sanitizeFilename(base) + ".epub";}