even more hacky but show all the archives

This commit is contained in:
2023-06-08 12:11:00 +02:00
parent f24f075cca
commit f59950d852
2 changed files with 19 additions and 9 deletions

View File

@@ -14,6 +14,8 @@
struct DirEntry {
std::unordered_map<std::string, DirEntry> children;
std::optional<File> file;
std::string name;
bool isFakeDir = false;
};
class RepoFS {

View File

@@ -18,15 +18,23 @@
RepoFS::RepoFS(Repository *repon, Object::idType archiveId, std::string path) : archive(Serialize::deserialize<Archive>(repon->getObject(archiveId))), path(std::move(path)) {
RepoFS::repo = repon;
for (auto const &f: archive.files) {
auto file = Serialize::deserialize<File>(repo->getObject(f));
auto path = std::filesystem::u8path(file.name);
DirEntry *entry = &root;
for (auto const &subp: path) {
entry = &entry->children[subp];
auto ars = repo->getObjects(Object::ObjectType::Archive);
for (auto const &r: ars) {
auto a = Serialize::deserialize<Archive>(repon->getObject(r.second));
for (auto const &f: a.files) {
auto file = Serialize::deserialize<File>(repo->getObject(f));
auto path = std::filesystem::u8path(file.name);
DirEntry *entry = &(root.children[r.first]);
entry->isFakeDir = true;
entry->name = a.name;
for (auto const &subp: path) {
entry = &entry->children[subp];
}
entry->file.emplace(file);
entry->name = std::filesystem::u8path(file.name).filename().u8string();
}
entry->file.emplace(file);
}
// thread = std::thread(&RepoFS::workerFn, this);
}
@@ -60,7 +68,7 @@ static int rfsGetattr(const char *path, struct stat *stbuf) {
DirEntry *e;
try {
e = getf(path);
if (e->file->fileType == File::Type::Directory) {
if (e->isFakeDir || e->file->fileType == File::Type::Directory) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 1;
} else if (e->file->fileType == File::Type::Normal) {
@@ -88,7 +96,7 @@ static int rfsReaddir(const char *path, void *buf, fuse_fill_dir_t filler,
filler(buf, "..", NULL, 0);
for (auto const &e: entry->children) {
auto pstr = std::filesystem::u8path(e.second.file->name).filename().u8string();
auto pstr = e.second.name;
std::cout << pstr << std::endl;
filler(buf, pstr.c_str(), NULL, 0);
}