iZeusify
iZeusify

Reputation: 140

std::filesystem::recursive_directory_iterator crashes when iterating over the executable itself

for (auto p : std::filesystem::recursive_directory_iterator(get_folder(), std::filesystem::directory_options::skip_permission_denied)) {
    const auto path = p.path().string();
    std::cout << path << std::endl;
}

so the code above crashes with Unhandled exception at 0x7FFA77095549 in project1.exe: Microsoft C++ exception: std::system_error at memory location 0x72E42FF360. the last directory it iterates over before it crashes is the directory where the source & executable are located. EDIT : get folder just returns the user folder

Upvotes: 1

Views: 1558

Answers (1)

iZeusify
iZeusify

Reputation: 140

fixed! the issue is std::filesystem cannot handle the the right to left override (U+202E) even when wstring is used. thats how i worked around it

if (p.path().wstring().find(L"\u202E") != std::string::npos)
            continue;
const auto path = p.path().string();
std::cout << path << std::endl;

Upvotes: 1

Related Questions