Boost filesystem iteration fails with a long path

1.9k views Asked by At

I'm trying to iterate into a folder using boost::filesystem, but when the path is too long (absolute path >95 chars), boost fail on iteration. Is some knows boost issue with this? Any idea to solve it?

while (itr != boost::filesystem::recursive_directory_iterator())
{
    ++itr;
}

I'm using boost 1.57, and VS2013.

1

There are 1 answers

0
Dale Wilson On BEST ANSWER

This is a windows problem, not a boost problem, and the only solution is to make your paths shorter or switch to Unicode for file system interactions which triggers a different set of issues if your program inherently uses 8 bit characters. Sorry.

Although Windows claims to support up to MAX_PATH characters (usually 260), in my experience you often encounter difficulties far before you reach that path length. As one example (not your problem, but an example) Visual Studio in particular assumes it will need to append extra junk to your paths so it reduces the actual usable path dramatically.

For more information, see the link posted by @JTejedor