]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
SCPathExists - function to see if a path exists
authorJason Ish <ish@unx.ca>
Thu, 4 Jan 2018 17:11:06 +0000 (11:11 -0600)
committerJason Ish <ish@unx.ca>
Thu, 18 Jan 2018 11:57:26 +0000 (05:57 -0600)
Returns true if path exists, otherwise false.

src/util-path.c
src/util-path.h

index d2989946b95c4209b0c421fa22b2e6184966d6b2..f4ba18326475e46de577e7565acddefc071520f4 100644 (file)
@@ -120,3 +120,20 @@ int SCCreateDirectoryTree(const char *path, const bool final)
 
     return 0;
 }
+
+/**
+ * \brief Check if a path exists.
+ *
+ * \param Path to check for existence
+ *
+ * \retval true if path exists
+ * \retval false if path does not exist
+ */
+bool SCPathExists(const char *path)
+{
+    struct stat sb;
+    if (stat(path, &sb) == 0) {
+        return true;
+    }
+    return false;
+}
index f425092e64753e74406e8319ad72bff4afb37d01..aeffe2c787feaf5f45772b061977927436a78bed 100644 (file)
@@ -35,5 +35,6 @@ int PathIsAbsolute(const char *);
 int PathIsRelative(const char *);
 int SCDefaultMkDir(const char *path);
 int SCCreateDirectoryTree(const char *path, const bool final);
+bool SCPathExists(const char *path);
 
 #endif /* __UTIL_PATH_H__ */