Opened 11 years ago

Closed 11 years ago

#5529 closed Bugs (duplicate)

Problem with boost::filesystem::path

Reported by: Leo Carreon <lcarreon@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.46.1 Severity: Problem
Keywords: Cc:

Description

Hi,

I upgraded my Boost libraries from version 1.45.0 to 1.46.1 and now the behavior of the following test program has changed:

#include <iostream> #include <iomanip> #include <boost/filesystem.hpp>

using std::cout; using std::endl; using boost::filesystem::path;

int main() {

path vPath("data/testfile"); vPath.make_preferred();

cout << "vPath = " << vPath.string() << endl;

}

When running the above on Windows using Boost version 1.45.0, I get the following result:

vPath = data\testfile

But now runnning the above on Windows using Boost version 1.46.1, I get the following result:

vPath = data/testfile

Was this behavior change intentional because the documentation states that the behavior should be as per the result using Boost 1.45.0.

Regards,

Leo

Change History (3)

comment:1 by Leo Carreon <lcarreon@…>, 11 years ago

Hi,

Can I please get some feedback on this.

Regards,

Leo

comment:2 by Leo Carreon <lcarreon@…>, 11 years ago

Hi,

What I meant in my original description of the problem above is that in Boost 1.46.1 the function path::make_preferred() is converting backslashes to slashes on a Windows environment which is contrary to what the documentation says.

I have looked in the Boost 1.46.1 source code and that is exactly what the code is doing, i.e. replacing backslashes with slashes using a std::replace() call. This new version of path::make_preferred() is now called by path::generic_string() and path::generic_wstring().

Whereas in Boost 1.45.0, path::make_preferred() converts slashes to backslashes and a private function path::m_portable() converts backslashes to slashes with both functions using a for loop to make the replacements. In this version, path::generic_string() and path::generic_wstring() call path::m_portable().

In my opinion, the 1.45.0 code is correct and could be improved by replacing the for loops with the std::replace() calls. A better name for path::m_portable() could be path::make_generic().

I have also checked the code in Boost 1.46.0, in this version path::make_preferred() is identical to that in Boost 1.45.0 thus the undocumented change is actually between Boost 1.46.0 and Boost 1.46.1.

I hope my explanation above clarifies this matter.

Regards,

Leo

comment:3 by anonymous, 11 years ago

Resolution: duplicate
Status: newclosed

This has been fixed on the release branch, see #5434.

Note: See TracTickets for help on using tickets.