Boost logo

Boost :

Subject: Re: [boost] [filesystem] Windows long paths (and also APIdifferences)
From: Adam Badura (abadura_at_[hidden])
Date: 2009-09-09 02:11:11

> Could you post your "simple test program"?

    The test program is:

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

int main()
        typedef boost::filesystem::path path_type;

        const path_type::string_type FOLDER_NAME = "Adam";

                path_type path( "D:/" );
                for ( int i = 0; i < 49; ++i )
                        path /= FOLDER_NAME;

                std::cout << path.external_directory_string()
                        << " (" << path.external_directory_string().size() << ")"
                        << std::endl;

                boost::filesystem::create_directories( path );
        catch ( ... )
                std::cerr << boost::current_exception_diagnostic_information();

        return 0;

    However I rechecked it. wchar_t indeed throws. I must have missed it
somehow. Sorry. My bad. But I was mistaken by create_directories side
effects. It created as much folders as possible and then threw without
deleting the folders it really created.
    In the example above 49 iterations is a limit. For 50 iterations there
is a failure of too long path. However for 50 iterations the path reaches
length of 252 so I do not understand why this error happens.
    And still there is a limit with this function.

> Windows has various rules, depending on the version, exact syntax
> used, etc. Thus it would help if you could be much more specific
> about the problem you are having, version of operating system, etc.

    Windows Vista Home Premium SP2.

    However all this seems to be Windows internal limitations. When I opened
the 49th created folder in Windows Explorer and tried to make a new folder
there I got a message of too long path. (Also pasting there a folder with 1
character name resulted in this error.) Even more interestingly making a new
file there works fine however the file starts with no name (only extension)
since the default new file name is too long. However the file accepts name
of 7 characters (so with extension it is 11).
    After all likely everything is fine with Boost.Filesystem. Sorry for

>> Also by the way I wanted to ask why signatures of many functions differ
>> from the documentation. For example no function takes error code
>> parameter
>> and thus always throws on failure (excluding the above example...). In
>> some
>> places I would prefer to have that parameter instead. Also copy_file does
>> not take the third parameter allowing it to do replacing.
>> Why is it so?
> It sounds like you are trying to use the V3 documentation from the
> sandbox with the current 1.40.0 V2 release. That's a non-starter.

    No. I never do. I used
And I went there in what I guess is a standard way. Boost Main Page /
Documentation / 1.40.0 (Current Release) / Filesystem / Reference / Other
operations functions.

    Adam Badura

Boost list run by bdawes at, gregod at, cpdaniel at, john at