X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1c8c73ef7e2f1307c815cd11071f8c584436f9d5..4bd1f48f0bf1ad1703be680ec2a38d626c6a2668:/src/msg/msg_io.cpp diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index b4791450a6..715622867d 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -73,7 +73,8 @@ void MSG_file_dump (msg_file_t fd){ "\t\tStorage Id: '%s'\n" "\t\tStorage Type: '%s'\n" "\t\tFile Descriptor Id: %d", - fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->storageId, fd->storage_type, fd->desc_id); + fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->storageId.c_str(), fd->storage_type.c_str(), + fd->desc_id); } /** \ingroup msg_file @@ -200,10 +201,7 @@ int MSG_file_close(msg_file_t fd) */ msg_error_t MSG_file_unlink(msg_file_t fd) { - /* Find the host where the file is physically located (remote or local)*/ - msg_storage_t storage_src = simgrid::s4u::Storage::byName(fd->storageId); - msg_host_t attached_host = storage_src->getHost(); - fd->unlink(attached_host); + fd->unlink(); delete fd; return MSG_OK; } @@ -287,7 +285,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa msg_host_t dst_host; size_t longest_prefix_length = 0; - for (auto elm : host->getMountedStorages()) { + for (auto const& elm : host->getMountedStorages()) { std::string mount_point = std::string(fullpath).substr(0, elm.first.size()); if (mount_point == elm.first && elm.first.length() > longest_prefix_length) { /* The current mount name is found in the full path and is bigger than the previous*/ @@ -326,7 +324,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa /* Create file on remote host, write it and close it */ msg_file_t fd = new simgrid::s4u::File(fullpath, dst_host, nullptr); - fd->write(read_size, dst_host); + fd->write(read_size); delete fd; return MSG_OK; } @@ -391,7 +389,14 @@ sg_size_t MSG_storage_get_used_size(msg_storage_t storage) xbt_dict_t MSG_storage_get_properties(msg_storage_t storage) { xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)"); - return storage->getProperties(); + xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f); + std::map* props = storage->getProperties(); + if (props == nullptr) + return nullptr; + for (auto const& elm : *props) { + xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr); + } + return as_dict; } /** \ingroup msg_storage_management @@ -435,7 +440,7 @@ xbt_dynar_t MSG_storages_as_dynar() { std::map* storage_map = simgrid::s4u::allStorages(); xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr); - for (auto s : *storage_map) + for (auto const& s : *storage_map) xbt_dynar_push(res, &(s.second)); delete storage_map; return res; @@ -473,14 +478,14 @@ void *MSG_storage_get_data(msg_storage_t storage) xbt_dict_t MSG_storage_get_content(msg_storage_t storage) { std::map* content = storage->getContent(); - xbt_dict_t content_dict = xbt_dict_new_homogeneous(&free); + xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(xbt_free_f); - for (auto entry : *content) { + for (auto const& entry : *content) { sg_size_t* psize = static_cast(malloc(sizeof(sg_size_t))); *psize = entry.second; - xbt_dict_set(content_dict, entry.first.c_str(), psize, nullptr); + xbt_dict_set(content_as_dict, entry.first.c_str(), psize, nullptr); } - return content_dict; + return content_as_dict; } /** \ingroup msg_storage_management