Skip to content
Snippets Groups Projects
Commit 8be0b541 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Fix size reporting.

parent e7e3711d
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@
static std::string str;
static CURL* curl;
static std::map<std::string, page> pages;
time_t parse_timestring (const char* str_) {
char* str = new char[strlen(str_)];
......@@ -72,7 +73,6 @@ time_t parse_timestring (const char* str_) {
using namespace tinyxml2;
static std::map<std::string, page> pages;
page* get_page(const char* path) {
page* p = & pages[path];
......@@ -126,7 +126,7 @@ int getattr_callback(const char* path, struct stat* st) {
if (strcmp(path, "/") == 0) {
st->st_mode = S_IFDIR | 0555;
st->st_size = pages.size();
st->st_size = actual_size(pages);
} else {
......@@ -189,12 +189,25 @@ int readdir_callback (
// filler(buf, "Tottaly a file", NULL, 0);
for (auto kv : pages) {
if (! kv.second.init) continue;
filler(buf, kv.first.c_str(), NULL, 0);
}
return 0;
}
size_t actual_size (std::map<std::string, page>& pages) {
size_t size = 0;
for (auto kv : pages) {
if (! kv.second.init) continue;
++size;
}
return size;
}
/*
* Calls when file system gets mounted
*/
......
#define FUSE_USE_VERSION 28
#include <string>
#include <map>
#include <sys/types.h>
#include <fuse.h>
......@@ -23,3 +24,5 @@ extern "C" {
int read_callback (const char*, char*, size_t, off_t, struct fuse_file_info*);
int readdir_callback (const char*, void*, fuse_fill_dir_t, off_t, struct fuse_file_info*);
}
size_t actual_size (std::map<std::string, page>& pages);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment