Ticket #6813 (new Bugs)
canonical function converts root-directory separator from '\' to '/' on Windows
|Reported by:||Alex Goldberg <alex.goldberg@…>||Owned by:||bemandawes|
|Milestone:||To Be Determined||Component:||filesystem|
boost::filesystem::canonical reverses the path separator on rooted paths
Consider the following line:
boost::filesystem::path convertedPath = boost::filesystem::canonical("C:\\Foo\\Bar\\..\\Bar\\Baz");
On Windows, convertedPath is set to "C:/Foo\Bar\Baz", where I would expect it to be set to "C:\Foo\Bar\Baz"
The documentation states: "Returns: A canonical path that refers to the same file system object as absolute(p,base)."
If the input path has no symbolic links, 'dot' directories, or 'dot-dot' directories, then I would expect the output to match a call to boost::filesystem::absolute.
boost::filesystem::path canonicalPath = boost::filesystem::canonical("Bar\\Baz", "C:\\Foo"); boost::filesystem::path absolutePath = boost::filesystem::absolute("Bar\\Baz", "C:\\Foo");
canonicalPath is set to "C:/Foo\Bar\Baz", while absolutePath is set to "C:\Foo\Bar\Baz".
Looking at the implementation, this is related to the issue in ticket 5989 ( https://svn.boost.org/trac/boost/ticket/5989). I agree with the sentiments in that ticket, but if the behavior of the path iterator will not be changing, then I think the canonical function should be updated to preseve path consistency in Windows.