diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-12 22:35:49 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-12 22:35:49 +0200 |
commit | c6dc4cd4ea7433dfd560732574f73d4bfea400f3 (patch) | |
tree | 3372df39803b2cb95d09b4f7ba02f47986944d82 /fileutils.c | |
parent | dfad8a8016426d7fe198dc32973b01a1e075142e (diff) |
Starting on 'downloaded' command
Diffstat (limited to 'fileutils.c')
-rw-r--r-- | fileutils.c | 14 |
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; +} |