Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove depredecated dag-dotload example
[simgrid.git] / examples / cpp / io-file-system / s4u-io-file-system.cpp
index 0fcb3c381df4078bfc1837573457d2ec5c529276..1c13eb9fbfc74225c1d106334c00c0fccd6333de 100644 (file)
@@ -32,7 +32,7 @@ public:
 
     // Open a non-existing file to create it
     std::string filename     = "/scratch/tmp/data.txt";
-    auto* file               = new simgrid::s4u::File(filename, nullptr);
+    auto* file               = simgrid::s4u::File::open(filename, nullptr);
 
     sg_size_t write = file->write(200000); // Write 200,000 bytes
     XBT_INFO("Create a %llu bytes file named '%s' on /scratch", write, filename.c_str());
@@ -62,15 +62,15 @@ public:
     delete file_data;
 
     // Close the file
-    delete file;
+    file->close();
 
     show_info(disks);
 
     // Reopen the file and then unlink it
-    file = new simgrid::s4u::File("/scratch/tmp/simgrid.readme", nullptr);
+    file = simgrid::s4u::File::open("/scratch/tmp/simgrid.readme", nullptr);
     XBT_INFO("Unlink file: '%s'", file->get_path());
     file->unlink();
-    delete file; // Unlinking the file on "disk" does not free the object
+    file->close(); // Unlinking the file on "disk" does not close the file and free the object
 
     show_info(disks);
   }
@@ -81,7 +81,7 @@ int main(int argc, char** argv)
   simgrid::s4u::Engine e(&argc, argv);
   sg_storage_file_system_init();
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("host", simgrid::s4u::Host::by_name("bob"), MyHost());
+  simgrid::s4u::Actor::create("host", e.host_by_name("bob"), MyHost());
   e.run();
 
   return 0;