aboutsummaryrefslogtreecommitdiff
path: root/fileutils.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-12 22:35:49 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-12 22:35:49 +0200
commitc6dc4cd4ea7433dfd560732574f73d4bfea400f3 (patch)
tree3372df39803b2cb95d09b4f7ba02f47986944d82 /fileutils.c
parentdfad8a8016426d7fe198dc32973b01a1e075142e (diff)
Starting on 'downloaded' command
Diffstat (limited to 'fileutils.c')
-rw-r--r--fileutils.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fileutils.c b/fileutils.c
new file mode 100644
index 0000000..233138c
--- /dev/null
+++ b/fileutils.c
@@ -0,0 +1,14 @@
+#include "fileutils.h"
+
+#include <stdlib.h>
+#include <pwd.h>
+#include <unistd.h>
+
+const char* get_home_dir() {
+ const char *home_dir = getenv("HOME");
+ if(!home_dir) {
+ struct passwd *pw = getpwuid(getuid());
+ home_dir = pw->pw_dir;
+ }
+ return home_dir;
+}