Boost logo

Boost Users :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-04-24 17:36:23


I have another question.

Suppose I have the following:

boost::filesystem::path myPath( "C:/somefolder/somefile" );
myPath += ".txt";

Notice the 2nd line of code. This isn't legal. What is the cleanest way to
append an extension to a file path? I don't think /= will work; if I
remember correctly it will add "/.txt".

On Thu, Apr 24, 2008 at 3:00 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:

> I've read the documentation a little closer at this page:
> http://www.boost.org/doc/libs/1_35_0/libs/filesystem/doc/index.htm#tutorial
>
> I find that it will store paths as forward slashes, and only when you call
> basic_path::file_string() will it convert to the platform format. However at
> this time I cannot figure out if file_string() is returning a std::string
> by-reference or by-value (Still looking through the source for answers to
> this).
>
>
>
> On Thu, Apr 24, 2008 at 2:49 PM, Markus Svilans <msvilans_at_[hidden]>
> wrote:
>
>> Hi Robert,
>>
>> I have used Boost paths on Windows like this:
>>
>> namespace bf = boost::filesystem;
>> bf::path temp("C:\\Windows\\System32\\", bf::native);
>>
>> Adding the "native" parameter tells the path object it is parsing a
>> Windows path (if compiling on Windows).
>>
>> To my knowledge, the path object will always store paths in its own
>> internal format, which uses front slashes as directory separators. More
>> info on this is in the boost::filesystem documentation.
>>
>> The basic_path::file_string() method returns the path in the operating
>> system native format, if I'm not mistaken.
>>
>> Regards,
>> Markus.
>>
>>
>> Robert Dailey wrote:
>> > Hi,
>> >
>> > I create the following object:
>> >
>> > boost::filesystem::path mypath( "SomeFolder/OnWindows/SubFolder" );
>> >
>> > In Microsoft Windows, the standard slash direction is "\", so when I
>> > run the above in the debugger, I notice m_path is still using forward
>> > slashes ("/"). I would have expected the slashes to be normalized. Am
>> > I misunderstanding something? How can I construct a path object like
>> > above and have it normalize the slashes? Thanks.
>> > ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Boost-users mailing list
>> > Boost-users_at_[hidden]
>> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
>
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net