git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@88 d34b734f-a00e-4b39-a726-e4eeb87269abadeniz_1
| char const FilePath::DirectorySeparator = '/'; | char const FilePath::DirectorySeparator = '/'; | ||||
| #endif | #endif | ||||
| bool FilePath::isAbsolute(std::string const &path) { | |||||
| #ifdef _WIN32 | |||||
| return PathIsRelative(path.c_str()); | |||||
| #else | |||||
| if (path.empty()) { | |||||
| return false; | |||||
| } | |||||
| return ('/' == path[0]); | |||||
| #endif | |||||
| } | |||||
| std::string FilePath::join(std::initializer_list<std::string> components) { | std::string FilePath::join(std::initializer_list<std::string> components) { | ||||
| std::string path; | std::string path; | ||||
| if (!path.empty() && | if (!path.empty() && | ||||
| path.back() != FilePath::DirectorySeparator) { | path.back() != FilePath::DirectorySeparator) { | ||||
| path += FilePath::DirectorySeparator; | path += FilePath::DirectorySeparator; | ||||
| if (isAbsolute(component)) { | |||||
| throw std::invalid_argument("Attempted to use absolute path \"" + | |||||
| component + "\" where a relative path " | |||||
| "is required."); | |||||
| } | |||||
| } | } | ||||
| path += component; | path += component; |
| /// Directory separator character. | /// Directory separator character. | ||||
| static char const DirectorySeparator; | static char const DirectorySeparator; | ||||
| /** Check whether a path is absolute. | |||||
| This method whether the specified path is absolute or not. | |||||
| @param[in] path is the path to check. | |||||
| @returns true if the path is an absolute path, false | |||||
| otherwise. | |||||
| */ | |||||
| static bool isAbsolute(std::string const &path); | |||||
| /** Join path components. | /** Join path components. | ||||
| This method joins a veriable number of std::string inputs to | This method joins a veriable number of std::string inputs to |