Commit c7a2c80c authored by Brad King's avatar Brad King
Browse files

ENH: SplitPath now supports slashes in both directions in the input path but...

ENH: SplitPath now supports slashes in both directions in the input path but still produces forward slashes in the root component.
parent 571929e8
...@@ -2240,7 +2240,7 @@ void SystemTools::SplitPath(const char* p, ...@@ -2240,7 +2240,7 @@ void SystemTools::SplitPath(const char* p,
components.clear(); components.clear();
// Identify the root component. // Identify the root component.
const char* c = p; const char* c = p;
if(c[0] == '/' && c[1] == '/') if((c[0] == '/' && c[1] == '/') || (c[0] == '\\' && c[1] == '\\'))
{ {
// Network path. // Network path.
components.push_back("//"); components.push_back("//");
...@@ -2252,7 +2252,7 @@ void SystemTools::SplitPath(const char* p, ...@@ -2252,7 +2252,7 @@ void SystemTools::SplitPath(const char* p,
components.push_back("/"); components.push_back("/");
c += 1; c += 1;
} }
else if(c[0] && c[1] == ':' && c[2] == '/') else if(c[0] && c[1] == ':' && (c[2] == '/' || c[2] == '\\'))
{ {
// Windows path. // Windows path.
kwsys_stl::string root = "_:/"; kwsys_stl::string root = "_:/";
...@@ -2279,7 +2279,7 @@ void SystemTools::SplitPath(const char* p, ...@@ -2279,7 +2279,7 @@ void SystemTools::SplitPath(const char* p,
const char* last = first; const char* last = first;
for(;*last; ++last) for(;*last; ++last)
{ {
if(*last == '/') if(*last == '/' || *last == '\\')
{ {
// End of a component. Save it. // End of a component. Save it.
components.push_back(kwsys_stl::string(first, last-first)); components.push_back(kwsys_stl::string(first, last-first));
......
...@@ -292,8 +292,7 @@ public: ...@@ -292,8 +292,7 @@ public:
* The remaining components form the path. If there is a trailing * The remaining components form the path. If there is a trailing
* slash then the last component is the empty string. The * slash then the last component is the empty string. The
* components can be recombined as "c[0]c[1]/c[2]/.../c[n]" to * components can be recombined as "c[0]c[1]/c[2]/.../c[n]" to
* produce the original path. The input is assumed to be formatted * produce the original path.
* with forward slashes.
*/ */
static void SplitPath(const char* p, static void SplitPath(const char* p,
kwsys_stl::vector<kwsys_stl::string>& components); kwsys_stl::vector<kwsys_stl::string>& components);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment