#include <string>
#include <unordered_map>
#include "src/plugins/file_system/FileSystem.hpp"
class MyHost {
public:
void show_info(std::unordered_map<std::string, simgrid::s4u::Storage*> const& mounts)
{
for (auto const& kv : mounts) {
XBT_INFO(
" %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->
getCname(), mountpoint.c_str(),
}
}
void operator()()
{
std::unordered_map<std::string, simgrid::s4u::Storage*> const& mounts =
show_info(mounts);
simgrid::s4u::File*
file =
new simgrid::s4u::File(filename,
nullptr);
XBT_INFO(
"Create a %llu bytes file named '%s' on /sd1", write, filename.c_str());
show_info(mounts);
file->seek(0);
const sg_size_t read = file->read(file_size);
XBT_INFO(
"Read %llu bytes on %s", read, filename.c_str());
write = file->write(100000);
XBT_INFO(
"Write %llu bytes on %s", write, filename.c_str());
XBT_INFO(
"Move '%s' to '%s'", file->getPath(), newpath.c_str());
file->move(newpath);
XBT_INFO(
"User data attached to the file: %s", file_data->c_str());
delete file_data;
XBT_INFO(
"Get/set data for storage element: %s", storage->getCname());
XBT_INFO(
" Uninitialized storage data: '%s'", static_cast<char*>(storage->getUserdata()));
storage->setUserdata(
new std::string(
"Some user data"));
XBT_INFO(
" Set and get data: '%s'", storage_data->c_str());
delete storage_data;
file = new simgrid::s4u::File("/home/tmp/simgrid.readme", nullptr);
XBT_INFO(
"Unlink file: '%s'", file->getPath());
file->unlink();
show_info(mounts);
}
};
{
e.loadPlatform(argv[1]);
e.run();
return 0;
}