diff --git a/Foundation/src/Path.cpp b/Foundation/src/Path.cpp index 397f50529b..1c527be1fd 100644 --- a/Foundation/src/Path.cpp +++ b/Foundation/src/Path.cpp @@ -821,8 +821,14 @@ void Path::parseWindows(const std::string& path) _absolute = true; _device += d; ++it; - if (it == end || (*it != '\\' && *it != '/')) throw PathSyntaxException(path); - ++it; + if (it != end) + { + if ((*it != '\\' && *it != '/')) + { + throw PathSyntaxException(path); + } + ++it; + } } else --it; } diff --git a/Foundation/testsuite/src/PathTest.cpp b/Foundation/testsuite/src/PathTest.cpp index 5f9c3c6be9..dabe8f8aa6 100644 --- a/Foundation/testsuite/src/PathTest.cpp +++ b/Foundation/testsuite/src/PathTest.cpp @@ -836,6 +836,39 @@ void PathTest::testParseWindows4() } +void PathTest::testParseWindows5() +{ + Path p; + p.parse("C:", Path::PATH_WINDOWS); + assertTrue (!p.isRelative()); + assertTrue (p.isAbsolute()); + assertTrue (p.depth() == 0); + assertTrue (p.isDirectory()); + assertTrue (p.toString(Path::PATH_WINDOWS) == "C:\\"); + + p.parse("C:\\", Path::PATH_WINDOWS); + assertTrue (!p.isRelative()); + assertTrue (p.isAbsolute()); + assertTrue (p.depth() == 0); + assertTrue (p.isDirectory()); + assertTrue (p.toString(Path::PATH_WINDOWS) == "C:\\"); + + p.parse("\\\\?\\C:", Path::PATH_WINDOWS); + assertTrue (!p.isRelative()); + assertTrue (p.isAbsolute()); + assertTrue (p.depth() == 1); + assertTrue (p.isDirectory()); + assertTrue (p.toString(Path::PATH_WINDOWS) == "\\\\?\\C:\\"); + + p.parse("\\\\?\\C:\\", Path::PATH_WINDOWS); + assertTrue (!p.isRelative()); + assertTrue (p.isAbsolute()); + assertTrue (p.depth() == 1); + assertTrue (p.isDirectory()); + assertTrue (p.toString(Path::PATH_WINDOWS) == "\\\\?\\C:\\"); +} + + void PathTest::testParseVMS1() { Path p; @@ -1697,6 +1730,7 @@ CppUnit::Test* PathTest::suite() CppUnit_addTest(pSuite, PathTest, testParseWindows2); CppUnit_addTest(pSuite, PathTest, testParseWindows3); CppUnit_addTest(pSuite, PathTest, testParseWindows4); + CppUnit_addTest(pSuite, PathTest, testParseWindows5); CppUnit_addTest(pSuite, PathTest, testParseVMS1); CppUnit_addTest(pSuite, PathTest, testParseVMS2); CppUnit_addTest(pSuite, PathTest, testParseVMS3); diff --git a/Foundation/testsuite/src/PathTest.h b/Foundation/testsuite/src/PathTest.h index d29336693b..7ecf766828 100644 --- a/Foundation/testsuite/src/PathTest.h +++ b/Foundation/testsuite/src/PathTest.h @@ -33,6 +33,7 @@ class PathTest: public CppUnit::TestCase void testParseWindows2(); void testParseWindows3(); void testParseWindows4(); + void testParseWindows5(); void testParseVMS1(); void testParseVMS2(); void testParseVMS3();