From 2c29b6a5145a4c44cbef03197db64cd2d7decd15 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sun, 6 Nov 2022 16:28:17 -0800 Subject: Basic functionality for using autotools over basic Makefile --- src/unix/cache.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/unix/cache.c (limited to 'src/unix/cache.c') diff --git a/src/unix/cache.c b/src/unix/cache.c new file mode 100644 index 0000000..e618602 --- /dev/null +++ b/src/unix/cache.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include + +#include "../include/cache.h" +#include "../include/read_cfg.h" + +char *get_cache_path(bool create){ + char *path = malloc(sizeof(char) * BUF_LEN); + char *home = getenv("HOME"); + + assert(path != NULL); + + if(home == NULL){ + printf("Failed to save cache data: HOME is not set\n"); + free(path); + return NULL; + } + + //if create is asserted, build the path to the file + if(create){ + sprintf(path, "%s%c.cache%c", home, sep, sep); + mkdir(path, 0755); + + sprintf(path, "%s%c.cache%cterminal-media-launcher%c", home, sep, sep, sep); + mkdir(path, 0755); + } + + sprintf(path, "%s%c.cache%cterminal-media-launcher%cdata.bin", home, sep, sep, sep); + + return path; +} -- cgit