diff --git a/include/ignition/common/Filesystem.hh b/include/ignition/common/Filesystem.hh index fb765d523..af835d52f 100644 --- a/include/ignition/common/Filesystem.hh +++ b/include/ignition/common/Filesystem.hh @@ -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 diff --git a/src/Filesystem.cc b/src/Filesystem.cc index ba4fda7e8..b17777f44 100644 --- a/src/Filesystem.cc +++ b/src/Filesystem.cc @@ -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) {