簡體   English   中英

迭代可執行文件本身時,std :: filesystem :: recursive_directory_iterator崩潰

[英]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;
}

因此以上代碼在project1.exe中的0x7FFA77095549處發生未處理的異常而崩潰:Microsoft C ++異常:內存位置0x72E42FF360的std :: system_error。 在崩潰前進行迭代的最后一個目錄是源和可執行文件所在的目錄。 編輯:獲取文件夾只是返回用戶文件夾

固定! 問題是std :: filesystem無法處理從右到左的覆蓋(U + 202E),即使使用wstring也不行。 那就是我如何解決它

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM