Skip to content

Commit

Permalink
Merge pull request #5219 from lioncash/common
Browse files Browse the repository at this point in the history
FileSearch: Namespace functions under the Common namespace
  • Loading branch information
lioncash committed Apr 8, 2017
2 parents 579b753 + f7a2f6a commit 59d93f3
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Source/Core/Common/FileSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "Common/FileSearch.h"
#include "Common/FileUtil.h"

namespace Common
{
static std::vector<std::string>
FileSearchWithTest(const std::vector<std::string>& directories, bool recursive,
std::function<bool(const File::FSTEntry&)> callback)
Expand Down Expand Up @@ -57,3 +59,4 @@ std::vector<std::string> FindSubdirectories(const std::vector<std::string>& dire
return FileSearchWithTest(directories, true,
[&](const File::FSTEntry& entry) { return entry.isDirectory; });
}
} // namespace Common
3 changes: 3 additions & 0 deletions Source/Core/Common/FileSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
#include <string>
#include <vector>

namespace Common
{
std::vector<std::string> DoFileSearch(const std::vector<std::string>& exts,
const std::vector<std::string>& directories,
bool recursive = false);
std::vector<std::string> FindSubdirectories(const std::vector<std::string>& directories,
bool recursive);
} // namespace Common
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ GCMemcardDirectory::GCMemcardDirectory(const std::string& directory, int slot, u
hdr_file.ReadBytes(&m_hdr, BLOCK_SIZE);
}

std::vector<std::string> filenames = DoFileSearch({".gci"}, {m_save_directory});
std::vector<std::string> filenames = Common::DoFileSearch({".gci"}, {m_save_directory});

if (filenames.size() > 112)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ void InterfaceConfigPane::LoadGUIValues()

void InterfaceConfigPane::LoadThemes()
{
auto sv =
DoFileSearch({""}, {File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR},
/*recursive*/ false);
auto sv = Common::DoFileSearch(
{""}, {File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR},
/*recursive*/ false);
for (const std::string& filename : sv)
{
std::string name, ext;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/FrameTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ void CFrame::GameListChanged(wxCommandEvent& event)
break;
case IDM_PURGE_GAME_LIST_CACHE:
std::vector<std::string> rFilenames =
DoFileSearch({".cache"}, {File::GetUserPath(D_CACHE_IDX)});
Common::DoFileSearch({".cache"}, {File::GetUserPath(D_CACHE_IDX)});

for (const std::string& rFilename : rFilenames)
{
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/DolphinWX/GameListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,9 @@ void CGameListCtrl::ScanForISOs()
m_ISOFiles.clear();

const auto custom_titles = LoadCustomTitles();
auto rFilenames = DoFileSearch(GetFileSearchExtensions(), SConfig::GetInstance().m_ISOFolder,
SConfig::GetInstance().m_RecursiveISOFolder);
auto rFilenames =
Common::DoFileSearch(GetFileSearchExtensions(), SConfig::GetInstance().m_ISOFolder,
SConfig::GetInstance().m_RecursiveISOFolder);

if (rFilenames.size() > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/Input/InputConfigDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void InputConfigDialog::UpdateProfileComboBox()
pname += PROFILES_PATH;
pname += m_config.GetProfileName();

std::vector<std::string> sv = DoFileSearch({".ini"}, {pname});
std::vector<std::string> sv = Common::DoFileSearch({".ini"}, {pname});

wxArrayString strs;
for (const std::string& filename : sv)
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/OGL/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ std::string VideoBackend::GetDisplayName() const
static std::vector<std::string> GetShaders(const std::string& sub_dir = "")
{
std::vector<std::string> paths =
DoFileSearch({".glsl"}, {File::GetUserPath(D_SHADERS_IDX) + sub_dir,
File::GetSysDirectory() + SHADERS_DIR DIR_SEP + sub_dir});
Common::DoFileSearch({".glsl"}, {File::GetUserPath(D_SHADERS_IDX) + sub_dir,
File::GetSysDirectory() + SHADERS_DIR DIR_SEP + sub_dir});
std::vector<std::string> result;
for (std::string path : paths)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/HiresTextures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void HiresTexture::Update()
};

std::vector<std::string> filenames =
DoFileSearch(extensions, {texture_directory}, /*recursive*/ true);
Common::DoFileSearch(extensions, {texture_directory}, /*recursive*/ true);

const std::string code = game_id + "_";

Expand Down

0 comments on commit 59d93f3

Please sign in to comment.