Simplify findFiles

In this repo there is no need for a recursive iterator,
fix style and make it a standard iterator.

Change-Id: I076c71f6b0baa4dc4b478b972bdb2fb6086d3ce6
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 1e54477..cd44082 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -18,10 +18,9 @@
 #include <experimental/filesystem>
 #include <nlohmann/json.hpp>
 
-bool find_files(const std::experimental::filesystem::path &dir_path,
-                const std::string &match_string,
-                std::vector<std::experimental::filesystem::path> &found_paths,
-                unsigned int symlink_depth = 1);
+bool findFiles(const std::experimental::filesystem::path &dirPath,
+               const std::string &matchString,
+               std::vector<std::experimental::filesystem::path> &foundPaths);
 
 bool validateJson(const nlohmann::json &schemaFile,
                   const nlohmann::json &input);
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index 81df6e1..e9e35b8 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -961,8 +961,8 @@
 {
     // find configuration files
     std::vector<fs::path> jsonPaths;
-    if (!find_files(fs::path(configurationDirectory), R"(.*\.json)", jsonPaths,
-                    0))
+    if (!findFiles(fs::path(configurationDirectory),
+                   R"(.*\.json)", jsonPaths))
     {
         std::cerr << "Unable to find any configuration files in "
                   << configurationDirectory << "\n";
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index 8ae27fb..99dd731 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -610,7 +610,7 @@
         auto matchString = std::string("i2c*");
         std::vector<fs::path> i2cBuses;
 
-        if (!find_files(devDir, matchString, i2cBuses, 0))
+        if (!findFiles(devDir, matchString, i2cBuses))
         {
             std::cerr << "unable to find i2c devices\n";
             return;
@@ -659,7 +659,7 @@
     auto matchString = std::string("i2c*");
     std::vector<fs::path> i2cBuses;
 
-    if (!find_files(devDir, matchString, i2cBuses, 0))
+    if (!findFiles(devDir, matchString, i2cBuses))
     {
         std::cerr << "unable to find i2c devices\n";
         return 1;
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index 6b12ab6..d5ddb69 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -111,8 +111,8 @@
     const std::vector<std::experimental::filesystem::path> &i2cDevsBefore)
 {
     std::vector<std::experimental::filesystem::path> i2cDevsAfter;
-    find_files(std::experimental::filesystem::path(I2C_DEVS_DIR),
-               R"(i2c-\d+)", i2cDevsAfter, 0);
+    findFiles(std::experimental::filesystem::path(I2C_DEVS_DIR),
+              R"(i2c-\d+)", i2cDevsAfter);
 
     for (const auto &dev : i2cDevsAfter)
     {
@@ -222,8 +222,8 @@
     auto findMux = MUX_TYPES.find(type);
     if (findMux != MUX_TYPES.end())
     {
-        find_files(std::experimental::filesystem::path(I2C_DEVS_DIR),
-                   R"(i2c-\d+)", i2cDevsBefore, 0);
+        findFiles(std::experimental::filesystem::path(I2C_DEVS_DIR),
+                  R"(i2c-\d+)", i2cDevsBefore);
     }
 
     // compile dtbo and load overlay
@@ -257,8 +257,8 @@
 {
 
     std::vector<std::experimental::filesystem::path> paths;
-    if (!find_files(std::experimental::filesystem::path(TEMPLATE_DIR),
-                    R"(.*\.template)", paths, 0))
+    if (!findFiles(std::experimental::filesystem::path(TEMPLATE_DIR),
+                   R"(.*\.template)", paths))
     {
         std::cerr << "Unable to find any tempate files in " << TEMPLATE_DIR
                   << "\n";
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 6db1157..be7b35c 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -25,27 +25,20 @@
 
 namespace fs = std::experimental::filesystem;
 
-bool find_files(const fs::path &dir_path, const std::string &match_string,
-                std::vector<fs::path> &found_paths, unsigned int symlink_depth)
+bool findFiles(const fs::path &dirPath, const std::string &matchString,
+               std::vector<fs::path> &foundPaths)
 {
-    if (!fs::exists(dir_path))
+    if (!fs::exists(dirPath))
         return false;
 
-    fs::directory_iterator end_itr;
-    std::regex search(match_string);
+    std::regex search(matchString);
     std::smatch match;
-    for (auto &p : fs::recursive_directory_iterator(dir_path))
+    for (const auto &p : fs::directory_iterator(dirPath))
     {
         std::string path = p.path().string();
         if (std::regex_search(path, match, search))
         {
-            found_paths.emplace_back(p.path());
-        }
-        // since we're using a recursve iterator, these should only be symlink
-        // dirs
-        else if (is_directory(p) && symlink_depth)
-        {
-            find_files(p.path(), match_string, found_paths, symlink_depth - 1);
+            foundPaths.emplace_back(p.path());
         }
     }
     return true;