X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8cd2b8b1e341896e2b8c3e96eb3778316855504c..26aa7a809ed123b511f529fc9d0ac2c3c3b9f71d:/examples/s4u/io/s4u-io.cpp diff --git a/examples/s4u/io/s4u-io.cpp b/examples/s4u/io/s4u-io.cpp index fb4bc28113..ac0ff0f708 100644 --- a/examples/s4u/io/s4u-io.cpp +++ b/examples/s4u/io/s4u-io.cpp @@ -3,9 +3,11 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include #include #include "simgrid/s4u.hpp" +#include "src/plugins/file_system/FileSystem.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category"); @@ -20,12 +22,8 @@ public: simgrid::s4u::Storage* storage = kv.second; // Retrieve disk's information - sg_size_t free_size = storage->getSizeFree(); - sg_size_t used_size = storage->getSizeUsed(); - sg_size_t size = storage->getSize(); - - XBT_INFO(" %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getName(), mountpoint.c_str(), used_size, - free_size, size); + XBT_INFO(" %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getCname(), mountpoint.c_str(), + sg_storage_get_size_used(storage), sg_storage_get_size_free(storage), sg_storage_get_size(storage)); } } @@ -63,28 +61,33 @@ public: file->move(newpath); // Test attaching some user data to the file - file->setUserdata(xbt_strdup("777")); - XBT_INFO("User data attached to the file: %s", static_cast(file->getUserdata())); - xbt_free(file->getUserdata()); + file->setUserdata(new std::string("777")); + std::string* file_data = static_cast(file->getUserdata()); + XBT_INFO("User data attached to the file: %s", file_data->c_str()); + delete file_data; // Close the file delete file; // Now attach some user data to disk1 - XBT_INFO("Get/set data for storage element: %s", storage->getName()); + XBT_INFO("Get/set data for storage element: %s", storage->getCname()); XBT_INFO(" Uninitialized storage data: '%s'", static_cast(storage->getUserdata())); - storage->setUserdata(xbt_strdup("Some user data")); - XBT_INFO(" Set and get data: '%s'", static_cast(storage->getUserdata())); - - xbt_free(storage->getUserdata()); + storage->setUserdata(new std::string("Some user data")); + std::string* storage_data = static_cast(storage->getUserdata()); + XBT_INFO(" Set and get data: '%s'", storage_data->c_str()); + delete storage_data; } }; int main(int argc, char **argv) { simgrid::s4u::Engine e(&argc, argv); - e.loadPlatform("../../platforms/storage/storage.xml"); + sg_storage_file_system_init(); + const char* platffile = "../../platforms/storage/storage.xml"; + if (argc > 1) + platffile = argv[1]; + e.loadPlatform(platffile); simgrid::s4u::Actor::createActor("host", simgrid::s4u::Host::by_name("denise"), MyHost()); e.run();