+const Disk* File::find_local_disk_on(const Host* host)
+{
+ const Disk* d = nullptr;
+ size_t longest_prefix_length = 0;
+ for (auto const& disk : host->get_disks()) {
+ std::string current_mount;
+ if (disk->get_host() != host)
+ current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point(disk->get_host());
+ else
+ current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
+ mount_point_ = fullpath_.substr(0, current_mount.length());
+ if (mount_point_ == current_mount && current_mount.length() > longest_prefix_length) {
+ /* The current mount name is found in the full path and is bigger than the previous*/
+ longest_prefix_length = current_mount.length();
+ d = disk;
+ }
+ xbt_assert(longest_prefix_length > 0, "Can't find mount point for '%s' on '%s'", fullpath_.c_str(),
+ host->get_cname());
+ /* Mount point found, split fullpath_ into mount_name and path+filename*/
+ mount_point_ = fullpath_.substr(0, longest_prefix_length);
+ if (mount_point_ == std::string("/"))
+ path_ = fullpath_;
+ else
+ path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
+ XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
+ }
+ return d;
+}
+
+File::File(const std::string& fullpath, void* userdata) : File(fullpath, Host::current(), userdata) {}