|
@@ -3,16 +3,18 @@
|
|
using qlow::util::Path;
|
|
using qlow::util::Path;
|
|
|
|
|
|
#ifdef QLOW_TARGET_WINDOWS
|
|
#ifdef QLOW_TARGET_WINDOWS
|
|
-const std::string Path::dirSeparator = "\\";
|
|
|
|
|
|
+const std::string Path::dirSeparators = "\\/";
|
|
|
|
+const std::string Path::defaultDirSeparator = "\\";
|
|
#else
|
|
#else
|
|
-const std::string Path::dirSeparator = "/";
|
|
|
|
|
|
+const std::string Path::dirSeparators = "/";
|
|
|
|
+const std::string Path::defaultDirSeparator = "/";
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void Path::append(const Path& other)
|
|
void Path::append(const Path& other)
|
|
{
|
|
{
|
|
if (!endsWithSeparator())
|
|
if (!endsWithSeparator())
|
|
- path += dirSeparator;
|
|
|
|
|
|
+ path += defaultDirSeparator;
|
|
path += other.path;
|
|
path += other.path;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -21,7 +23,7 @@ Path Path::parentPath(void) const
|
|
{
|
|
{
|
|
Path parent = *this;
|
|
Path parent = *this;
|
|
|
|
|
|
- if (parent.path == dirSeparator)
|
|
|
|
|
|
+ if (parent.path == defaultDirSeparator)
|
|
return parent;
|
|
return parent;
|
|
|
|
|
|
if (parent.endsWithSeparator()) {
|
|
if (parent.endsWithSeparator()) {
|
|
@@ -33,7 +35,7 @@ Path Path::parentPath(void) const
|
|
parent.path.pop_back();
|
|
parent.path.pop_back();
|
|
}
|
|
}
|
|
|
|
|
|
- if (parent.path.size() > dirSeparator.size() && parent.endsWithSeparator())
|
|
|
|
|
|
+ if (parent.path.size() >= 2 && parent.endsWithSeparator())
|
|
parent.path.pop_back();
|
|
parent.path.pop_back();
|
|
|
|
|
|
return parent;
|
|
return parent;
|
|
@@ -68,6 +70,7 @@ const char* Path::c_str(void) const
|
|
|
|
|
|
bool Path::endsWithSeparator(void) const
|
|
bool Path::endsWithSeparator(void) const
|
|
{
|
|
{
|
|
- return path.size() >= dirSeparator.size() &&
|
|
|
|
- std::equal(dirSeparator.rbegin(), dirSeparator.rend(), path.rbegin());
|
|
|
|
|
|
+ return !path.empty() && dirSeparators.find(path[path.size() - 1]) != std::string::npos;
|
|
|
|
+ /*return path.size() >= dirSeparator.size() &&
|
|
|
|
+ std::equal(dirSeparator.rbegin(), dirSeparator.rend(), path.rbegin());*/
|
|
}
|
|
}
|