Check if image upload dir exists

The inotify doesn't work if the image upload
dir doesn't exist. If the image dir doesn't exist log an error.

Change-Id: I2b8c49182f2f19b8343587f4723575b6f6fc8781
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/watch.cpp b/watch.cpp
index ae1e419..da1f967 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -4,6 +4,7 @@
 #include <string>
 #include <sys/inotify.h>
 #include <unistd.h>
+#include <experimental/filesystem>
 #include <phosphor-logging/log.hpp>
 #include "config.h"
 #include "watch.hpp"
@@ -18,9 +19,20 @@
 
 using namespace phosphor::logging;
 using namespace std::string_literals;
+namespace fs = std::experimental::filesystem;
 
 Watch::Watch(sd_event* loop)
 {
+    // Check if IMAGE DIR exists.
+    fs::path imgDirPath(IMG_UPLOAD_DIR);
+    if (!fs::is_directory(imgDirPath))
+    {
+        log<level::ERR>("ERROR No Image Dir",
+                        entry("IMAGEDIR=%s", IMG_UPLOAD_DIR));
+        throw std::runtime_error(
+            "No Image Dir, IMAGEDIR=" + std::string{IMG_UPLOAD_DIR});
+    }
+
     fd = inotify_init1(IN_NONBLOCK);
     if (-1 == fd)
     {