return PathIsAbsolute(path) ? 0 : 1;
}
-/** \brief Recursively create missing log directories.
- * \param path path to log file
- * \retval 0 on success
- * \retval -1 on error
+/**
+ * \brief Wrapper around SCMkDir with default mode arguments.
+ */
+int SCDefaultMkDir(const char *path)
+{
+ return SCMkDir(path, S_IRWXU | S_IRGRP | S_IXGRP);
+}
+
+/**
+ * \brief Recursively create a directory.
+ *
+ * \param path Path to create
+ * \param final true will create the final path component, false will not
+ *
+ * \retval 0 on success
+ * \retval -1 on error
*/
-int SCCreateDirectoryTree(const char *path)
+int SCCreateDirectoryTree(const char *path, const bool final)
{
char pathbuf[PATH_MAX];
char *p;
/* Truncate, while creating directory */
*p = '\0';
- if (SCMkDir(pathbuf, S_IRWXU | S_IRGRP | S_IXGRP) != 0) {
+ if (SCDefaultMkDir(pathbuf) != 0) {
if (errno != EEXIST) {
return -1;
}
}
}
+ if (final) {
+ if (SCDefaultMkDir(pathbuf) != 0) {
+ if (errno != EEXIST) {
+ return -1;
+ }
+ }
+ }
+
return 0;
}
int PathIsAbsolute(const char *);
int PathIsRelative(const char *);
-int SCCreateDirectoryTree(const char *path);
+int SCDefaultMkDir(const char *path);
+int SCCreateDirectoryTree(const char *path, const bool final);
#endif /* __UTIL_PATH_H__ */