+FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr)
+{
+ content_ = parseContent(ptr->getImpl()->content_name);
+}
+
+FileSystemStorageExt::~FileSystemStorageExt()
+{
+ delete content_;
+}
+
+std::map<std::string, sg_size_t>* FileSystemStorageExt::parseContent(std::string filename)
+{
+ if (filename.empty())
+ return nullptr;
+
+ std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
+
+ std::ifstream* fs = surf_ifsopen(filename);
+
+ std::string line;
+ std::vector<std::string> tokens;
+ do {
+ std::getline(*fs, line);
+ boost::trim(line);
+ if (line.length() > 0) {
+ boost::split(tokens, line, boost::is_any_of(" \t"), boost::token_compress_on);
+ xbt_assert(tokens.size() == 2, "Parse error in %s: %s", filename.c_str(), line.c_str());
+ sg_size_t size = std::stoull(tokens.at(1));
+
+ usedSize_ += size;
+ parse_content->insert({tokens.front(), size});
+ }
+ } while (not fs->eof());
+ delete fs;
+ return parse_content;
+}
+}
+}
+
+using simgrid::s4u::FileSystemStorageExt;
+
+static void onStorageCreation(simgrid::s4u::Storage& st)
+{
+ st.extension_set(new FileSystemStorageExt(&st));
+}
+
+static void onStorageDestruction(simgrid::s4u::Storage& st)
+{
+ XBT_INFO("BLIH");
+}
+
+/* **************************** Public interface *************************** */
+SG_BEGIN_DECL()
+
+void sg_storage_file_system_init()
+{
+
+ if (FileSystemStorageExt::EXTENSION_ID.valid())
+ return;
+
+ FileSystemStorageExt::EXTENSION_ID = simgrid::s4u::Storage::extension_create<FileSystemStorageExt>();
+
+ simgrid::s4u::Storage::onCreation.connect(&onStorageCreation);
+ simgrid::s4u::Storage::onDestruction.connect(&onStorageDestruction);
+}
+
+SG_END_DECL()