Skip to content

Commit

Permalink
tmp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Oct 5, 2024
1 parent 4fb9231 commit 9235166
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/fsmod/FileSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ namespace simgrid::fsmod {
[[nodiscard]] std::vector<std::shared_ptr<Partition>> get_partitions() const;
[[nodiscard]] std::shared_ptr<Partition> get_partition_for_path_or_null(const std::string& full_path) const;

[[nodiscard]] sg_size_t get_free_space_at_path(const std::string &full_path) const;

private:
friend class File;

Expand Down
15 changes: 13 additions & 2 deletions src/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ namespace simgrid::fsmod {
* @return
*/
std::shared_ptr<File> FileSystem::open(const std::string &full_path, const std::string& access_mode) {
std::cerr << "FSMON: OPENING FILE\n";
// "Get a file descriptor"
if (this->num_open_files_ >= this->max_num_open_files_) {
throw TooManyOpenFilesException(XBT_THROW_POINT);
Expand Down Expand Up @@ -337,7 +336,6 @@ namespace simgrid::fsmod {
file->current_position_ = metadata->get_current_size();

this->num_open_files_++;
std::cerr << "FSMON: DONE OPENING FILE\n";
return file;
}

Expand Down Expand Up @@ -467,4 +465,17 @@ namespace simgrid::fsmod {
partition->delete_directory(path_at_mount_point);
}


/**
* @brief Returns the free space on the path's partition
* @param full_path: a path
* @return a number of bytes
*/
sg_size_t FileSystem::get_free_space_at_path(const std::string &full_path) const {
std::string simplified_path = PathUtil::simplify_path_string(full_path);
auto [partition, path_at_mount_point] = this->find_path_at_mount_point(simplified_path);
return partition->get_free_space();
}


}
3 changes: 2 additions & 1 deletion src/PathUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ namespace simgrid::fsmod {
* @return True if mount_point is a prefix of simplified_absolute_path, false otherwise
*/
bool PathUtil::is_at_mount_point(std::string_view simplified_absolute_path, std::string_view mount_point) {
return simplified_absolute_path.rfind(mount_point, 0) == 0;
bool to_return = simplified_absolute_path.rfind(mount_point, 0) == 0;
return to_return;
}

/**
Expand Down

0 comments on commit 9235166

Please sign in to comment.