|
|
@@ -50,6 +50,19 @@ namespace CodeDweller { |
|
|
|
char const FilePath::DirectorySeparator = '/';
|
|
|
|
#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 path;
|
|
|
@@ -59,6 +72,13 @@ namespace CodeDweller { |
|
|
|
if (!path.empty() &&
|
|
|
|
path.back() != 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;
|