Don't attempt to iterate non-existant folders

Put a is_directory() check before iterating so we
don't throw on a bad folder.

Tested-by: Entity manager was up when a mux was added
on non-existant bus

Change-Id: I96b3f74b69560e9a5f9f1b614c08866259a262b7
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index c1b6de4..4bc733f 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -235,19 +235,23 @@
         std::string busStr = std::to_string(*bus);
 
         std::filesystem::path devicePath(device);
-        const std::string& dir = devicePath.parent_path().string();
-        for (const auto& path : std::filesystem::directory_iterator(dir))
+        std::filesystem::path parentPath = devicePath.parent_path();
+        if (std::filesystem::is_directory(parentPath))
         {
-            if (!std::filesystem::is_directory(path))
+            for (const auto& path :
+                 std::filesystem::directory_iterator(parentPath))
             {
-                continue;
-            }
+                if (!std::filesystem::is_directory(path))
+                {
+                    continue;
+                }
 
-            const std::string& directoryName = path.path().filename();
-            if (boost::starts_with(directoryName, busStr) &&
-                boost::ends_with(directoryName, addressHex))
-            {
-                return; // already exported
+                const std::string& directoryName = path.path().filename();
+                if (boost::starts_with(directoryName, busStr) &&
+                    boost::ends_with(directoryName, addressHex))
+                {
+                    return; // already exported
+                }
             }
         }
     }