summaryrefslogtreecommitdiff
path: root/src/util/fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/fs.h')
-rw-r--r--src/util/fs.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/util/fs.h b/src/util/fs.h
new file mode 100644
index 0000000..9dc445f
--- /dev/null
+++ b/src/util/fs.h
@@ -0,0 +1,40 @@
+#ifndef _SK_UTIL_FS_H
+#define _SK_UTIL_FS_H
+
+#include "../../config.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <limits.h>
+#include <pwd.h>
+#include <sys/stat.h>
+
+#if HAVE_STDBOOL_H
+#include <stdbool.h>
+#endif
+
+/**
+ * is_dir:
+ * Check if a given pathname is a directory.
+ *
+ * @returns true if the given pathname exists and is a directory, false
+ * otherwise.
+ */
+bool is_dir(const char *restrict pathname);
+
+/**
+ * myhome:
+ * Returns a pointer to a string containing the current user’s home
+ * directory.
+ * The returned pointer points to a static location (don’t free() it) and
+ * may be changed on future invocations.
+ *
+ * This function makes sure that the returned string is null-terminated and
+ * truncates the result to fit within PATH_MAX if necessary.
+ *
+ * @returns home dir
+ */
+const char *myhome();
+
+#endif