#include
namespace obb::discover {
namespace {
std::vector s_entries;
std::string s_root;
uint32_t fake_crc32(const std::string &path) {
uint32_t crc = 0;
for (char c : path) {
crc = (crc << 5) ^ static_cast(c);
}
return crc;
}
MediaType guess_type(const std::string &path) {
std::string ext;
const auto pos = path.find_last_of('.');
if (pos != std::string::npos) {
ext = path.substr(pos);
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); });
}
if (ext == ".mp3" || ext == ".wav") return MediaType::kAudio;
if (ext == ".jpg" || ext == ".png") return MediaType::kImage;
if (ext == ".tile" || ext == ".map") return MediaType::kMapTile;
return MediaType::kArticle;
}
void add_stub_entry(const std::string &path, const char *desc) {
ContentEntry ce;
ce.path = path;
ce.title = path.substr(path.find_last">
#include
namespace obb::discover {
namespace {
std::vector s_entries;
std::string s_root;
uint32_t fake_crc32(const std::string &path) {
uint32_t crc = 0;
for (char c : path) {
crc = (crc << 5) ^ static_cast(c);
}
return crc;
}
MediaType guess_type(const std::string &path) {
std::string ext;
const auto pos = path.find_last_of('.');
if (pos != std::string::npos) {
ext = path.substr(pos);
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); });
}
if (ext == ".mp3" || ext == ".wav") return MediaType::kAudio;
if (ext == ".jpg" || ext == ".png") return MediaType::kImage;
if (ext == ".tile" || ext == ".map") return MediaType::kMapTile;
return MediaType::kArticle;
}
void add_stub_entry(const std::string &path, const char *desc) {
ContentEntry ce;
ce.path = path;
ce.title = path.substr(path.find_last">
#include
namespace obb::discover {
namespace {
std::vector s_entries;
std::string s_root;
uint32_t fake_crc32(const std::string &path) {
uint32_t crc = 0;
for (char c : path) {
crc = (crc << 5) ^ static_cast(c);
}
return crc;
}
MediaType guess_type(const std::string &path) {
std::string ext;
const auto pos = path.find_last_of('.');
if (pos != std::string::npos) {
ext = path.substr(pos);
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); });
}
if (ext == ".mp3" || ext == ".wav") return MediaType::kAudio;
if (ext == ".jpg" || ext == ".png") return MediaType::kImage;
if (ext == ".tile" || ext == ".map") return MediaType::kMapTile;
return MediaType::kArticle;
}
void add_stub_entry(const std::string &path, const char *desc) {
ContentEntry ce;
ce.path = path;
ce.title = path.substr(path.find_last">
#include "app/ui/discover/obb_discover_library.h"
#include <algorithm>
#include <cctype>
namespace obb::discover {
namespace {
std::vector<ContentEntry> s_entries;
std::string s_root;
uint32_t fake_crc32(const std::string &path) {
uint32_t crc = 0;
for (char c : path) {
crc = (crc << 5) ^ static_cast<uint32_t>(c);
}
return crc;
}
MediaType guess_type(const std::string &path) {
std::string ext;
const auto pos = path.find_last_of('.');
if (pos != std::string::npos) {
ext = path.substr(pos);
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); });
}
if (ext == ".mp3" || ext == ".wav") return MediaType::kAudio;
if (ext == ".jpg" || ext == ".png") return MediaType::kImage;
if (ext == ".tile" || ext == ".map") return MediaType::kMapTile;
return MediaType::kArticle;
}
void add_stub_entry(const std::string &path, const char *desc) {
ContentEntry ce;
ce.path = path;
ce.title = path.substr(path.find_last_of("/\\\\") + 1);
ce.description = desc ? desc : "Hors-ligne";
ce.type = guess_type(path);
ce.bytes = 0;
ce.checksum = fake_crc32(path);
s_entries.push_back(std::move(ce));
}
} // namespace
void library_init(const char *root_folder) {
s_root = root_folder ? root_folder : "";
s_entries.clear();
if (!s_root.empty()) {
add_stub_entry(s_root + "/welcome.txt", "Bienvenue (placeholder)");
add_stub_entry(s_root + "/map.tile", "Tuile cartographique");
add_stub_entry(s_root + "/[radio.mp](<http://radio.mp>)3", "Audio local");
}
std::sort(s_entries.begin(), s_entries.end(), [](const ContentEntry &a, const ContentEntry &b) {
return a.title < b.title;
});
}
std::vector<ContentEntry> list_recent(std::size_t limit) {
std::vector<ContentEntry> out;
out.reserve(std::min(limit, s_entries.size()));
for (const auto &entry : s_entries) {
out.push_back(entry);
if (out.size() >= limit) break;
}
return out;
}
std::vector<ContentEntry> filter_by_type(MediaType type, std::size_t limit) {
std::vector<ContentEntry> out;
for (const auto &entry : s_entries) {
if (entry.type != type) continue;
out.push_back(entry);
if (out.size() >= limit) break;
}
return out;
}
} // namespace obb::discover