I want to get all the files inside a concrete folder (in this case Documents) with Boost Filesystem in Windows.
For this I make a filter to assure I get no folders.
The problem is that when I still get the following folders :
"C:\....\Documents\My Videos",
"C:\....\Documents\My Music",
"C:\....\Documents\My Pictures"
(I don't get some other folders)
The code is the following:
boost::filesystem::directory_iterator end;
for (boost::filesystem::directory_iterator iter(documentsFolder); iter != end; ++iter){
if (!is_directory(*iter)){
std::cout << iter->path() << "\n";
}
else{
std::cout << "-------->>>" << iter->path() << "\n";
}
Is there any way to avoid this folders without making a manual filtering?
Thanks a lot!
These are likely junctions.
I just tried it on a windows box by using
junction.exe
(from sysinternals) to make a junction point, and using this little test program to pinpoint them:Now running this with
test.exe "C:\WORK"
printedNote that the
assers
prove that is neither a regular file nor a directory.In slightly unrelated news, this is rather sweet for directory iteration:
Using these rather simple helpers:
See it Live on Coliru