+int File::remote_copy(sg_host_t host, const char* fullpath)
+{
+ /* Find the host where the file is physically located and read it */
+ Storage* storage_src = local_storage_;
+ Host* src_host = storage_src->get_host();
+ seek(0, SEEK_SET);
+ XBT_DEBUG("READ %s on disk '%s'", get_path(), local_storage_->get_cname());
+ // if the current position is close to the end of the file, we may not be able to read the requested size
+ sg_size_t read_size = local_storage_->read(size_);
+ current_position_ += read_size;
+
+ /* Find the host that owns the storage where the file has to be copied */
+ Storage* storage_dest = nullptr;
+ Host* dst_host;
+ size_t longest_prefix_length = 0;
+
+ for (auto const& elm : host->get_mounted_storages()) {
+ 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*/
+ longest_prefix_length = elm.first.length();
+ storage_dest = elm.second;
+ }
+ }
+
+ if (storage_dest != nullptr) {
+ /* Mount point found, retrieve the host the storage is attached to */
+ dst_host = storage_dest->get_host();
+ } else {
+ XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->get_cname());
+ return -1;
+ }
+
+ XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, src_host->get_cname(),
+ storage_dest->get_host()->get_cname());
+ std::vector<Host*> m_host_list = {src_host, dst_host};
+ std::vector<double> flops_amount = {0, 0};
+ std::vector<double> bytes_amount = {0, static_cast<double>(read_size), 0, 0};
+
+ this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
+
+ /* Create file on remote host, write it and close it */
+ File* fd = new File(fullpath, dst_host, nullptr);
+ sg_size_t write_size = fd->local_storage_->write(read_size);
+ fd->local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
+ (*(fd->local_storage_->extension<FileSystemStorageExt>()->get_content()))[path_] = size_;
+ delete fd;
+ return 0;
+}
+
+int File::remote_move(sg_host_t host, const char* fullpath)
+{
+ int res = remote_copy(host, fullpath);
+ unlink();
+ return res;
+}
+