From 63bb646721517a4b00c1b19d137dc5be1a14ec8f Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 20 Jun 2019 18:29:29 +0200 Subject: [PATCH] Fix opening controller config when there is no profile directory https://bugs.dolphin-emu.org/issues/11771 --- Source/Core/Common/FileSearch.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Source/Core/Common/FileSearch.cpp b/Source/Core/Common/FileSearch.cpp index 561e1136e6..b37e0cc5cd 100644 --- a/Source/Core/Common/FileSearch.cpp +++ b/Source/Core/Common/FileSearch.cpp @@ -97,16 +97,20 @@ std::vector DoFileSearch(const std::vector& directorie }; for (const auto& directory : directories) { - if (recursive) + const fs::path directory_path = fs::u8path(directory); + if (fs::is_directory(directory_path)) // Can't create iterators for non-existant directories { - // TODO use fs::directory_options::follow_directory_symlink ? - for (auto& entry : fs::recursive_directory_iterator(fs::u8path(directory))) - add_filtered(entry); - } - else - { - for (auto& entry : fs::directory_iterator(fs::u8path(directory))) - add_filtered(entry); + if (recursive) + { + // TODO use fs::directory_options::follow_directory_symlink ? + for (auto& entry : fs::recursive_directory_iterator(std::move(directory_path))) + add_filtered(entry); + } + else + { + for (auto& entry : fs::directory_iterator(std::move(directory_path))) + add_filtered(entry); + } } }