overlay: Simplify path-checking in buildDevice

We know the path we're looking for, so we don't need to go into
directory reading and recursion to check if it's there, we can just do a
direct lookup instead.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: Ica84ebc757fc990b1a2477f162008f0f36d937bd
diff --git a/src/overlay.cpp b/src/overlay.cpp
index 4cb3181..966bfd1 100644
--- a/src/overlay.cpp
+++ b/src/overlay.cpp
@@ -167,40 +167,16 @@
         return false;
     }
 
-    std::string dirName = deviceDirName(*bus, *address);
+    std::filesystem::path dirPath = busPath;
+    dirPath /= deviceDirName(*bus, *address);
+    if (createsHWMon)
+    {
+        dirPath /= "hwmon";
+    }
 
     std::error_code ec;
-    auto path = std::filesystem::recursive_directory_iterator(busPath, ec);
-    if (ec)
-    {
-        std::cerr << "Unable to open path " << busPath << "\n";
-        return false;
-    }
-    for (; path != std::filesystem::recursive_directory_iterator(); path++)
-    {
-        if (!std::filesystem::is_directory(*path))
-        {
-            continue;
-        }
-
-        const std::string foundName = path->path().filename();
-        if (foundName == dirName)
-        {
-            // Look for a .../hwmon subdirectory for devices that are expected
-            // to have one.
-            if (createsHWMon)
-            {
-                std::error_code ec;
-                std::filesystem::path hwmonDir(busPath);
-                hwmonDir /= dirName;
-                hwmonDir /= "hwmon";
-                return std::filesystem::is_directory(hwmonDir, ec);
-            }
-            return true;
-        }
-        path.disable_recursion_pending();
-    }
-    return false;
+    // Ignore errors; anything but a clean 'true' is just fine as 'false'
+    return std::filesystem::exists(dirPath, ec);
 }
 
 static int buildDevice(const std::string& busPath,