/* Find the host where the file is physically located and read it */
msg_storage_t storage_src = simgrid::s4u::Storage::byName(fd->storageId);
msg_host_t attached_host = storage_src->getHost();
- read_size = fd->read(size); // TODO re-add attached_host;
+ read_size = fd->read(size); // TODO re-add attached_host
if (strcmp(attached_host->getCname(), MSG_host_self()->getCname())) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
}
/* Write file on local or remote host */
// sg_size_t offset = fd->tell();
- sg_size_t write_size = fd->write(size); // TODO readd attached_host;
+ sg_size_t write_size = fd->write(size); // TODO readd attached_host
return write_size;
}
*/
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;
}
/* 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;
}
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::unordered_map<std::string, std::string>* props = storage->getProperties();
+ if (props == nullptr)
+ return nullptr;
+ for (auto 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
xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
{
std::map<std::string, sg_size_t>* 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) {
sg_size_t* psize = static_cast<sg_size_t*>(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