The problem is that older versions of Boost filesystem (V2) on Windows used VC++'s stat()
function to obtain the information on the target file, and that function followed symlinks.
Newer versions of the filesystem library (V3) use the the Win32 GetFileAttributesExW()
API, and it doesn't follow symlinks, so the size of the object specified by the path gets returned as 0.
It looks like filesystem V3 was made the default in Boost 1.46 and V2 was removed from the library in 1.48. One possible fix for your problem is to move back to a version of Boost before 1.48 (and possibly build the libraries with the BOOST_FILESYSTEM_VERSION
macro set to 2).
I have opened a bug against this and the bug report includes a patch against libs/filesystem/src/operations.cpp
that fixes the problem:
Keep in mind that the patch I submitted in the bug report hasn't had much testing (for example, it needs to be tested against other versions of Windows, with the MinGW toolchain, with paths that include characters outside the ASCII range, directories as targets, and probably a number of other things I haven't thought of). However, if you want to continue using a recent Boost release, you're welcome to patch your local Boost libs to see if it solves the problem for you.