Ticket #6821 (closed Bugs: fixed)
recursive_directory_iterator: increment fails with 'access denied'
|Reported by:||Gary Sanders <lex21@…>||Owned by:||bemandawes|
|Milestone:||To Be Determined||Component:||filesystem|
This issue is found on Windows 7 x64, Win32 binary built with Visual Studio 2010. See attachment for sample program.
Recursive iteration fails when iterating a directory that contains a child directory for which the user does not have permission to access. The attached program illustrates this issue, assuming that the user has at least one directory that the current users does not have permission to access:
boost::filesystem::directory_iterator::construct: Access is denied: "c:\$Recycle.Bin\S-1-5-20"
The exception is caused by FindFirstFileW() returning ERROR_ACCESS_DENIED. This function is located in dir_itr_first(), filesystem/v3/src/operations.cpp, line 2000.
Intuitively this iteration should work and any directories for which the user does not have permission to access should be ignored. Though, perhaps there are at least two use cases for this behaviour when encountering a directory for which the user does not have permission to access:
- Iteration is not expected to fail with an 'access denied' error, so if it encounters this situation throw an error. (The current behaviour.)
- It is unknown if the directory being recursively iterated contains one or more directories for which the user does not have access. Therefore, these directories should be ignored and processing allowed to continue.
One solution might be to allow a flag to be passed in the constructor that would define which of the two behaviours to invoke.
- Version changed from Boost 1.49.0 to Boost 1.55.0
- Severity changed from Problem to Showstopper