Skip to content

Commit

Permalink
Adds an isRelativePath to determine if path is relative
Browse files Browse the repository at this point in the history
This PR adds an `isRelativePath` function to ign-common Filesystem.hh. It is a simple wrapper around `std::filesystem`.  The rationale for this is so we can remove `std::Filesystem` from ign-gazebo as this is causing other issues such as gazebo-tooling/release-tools#639.

Signed-off-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
arjo129 committed Feb 16, 2022
1 parent e79b31f commit a388068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/ignition/common/Filesystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ namespace ignition
/// \return True if _path is a file.
bool IGNITION_COMMON_VISIBLE isFile(const std::string &_path);

/// \brief Check if the given path is relative.
/// \param[in] _path Path.
/// \return True if _path is relative.
bool IGNITION_COMMON_VISIBLE isRelativePath(const std::string &_path);

/// \brief Create a new directory on the filesystem. Intermediate
/// directories must already exist.
/// \param[in] _path The new directory path to create
Expand Down
6 changes: 6 additions & 0 deletions src/Filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ bool ignition::common::isFile(const std::string &_path)
return fs::is_regular_file(_path);
}

/////////////////////////////////////////////////
bool ignition::common::isRelativePath(const std::string &_path)
{
return fs::path(_path).is_relative();
}

/////////////////////////////////////////////////
bool ignition::common::createDirectory(const std::string &_path)
{
Expand Down

0 comments on commit a388068

Please sign in to comment.