diff options
| author | Aargh Rai <shubh2007rai@gmail.com> | 2026-03-28 19:03:45 +0530 |
|---|---|---|
| committer | Aargh Rai <shubh2007rai@gmail.com> | 2026-03-28 19:03:45 +0530 |
| commit | c7194b9b07a9c80344b52e002d0863fd258f0b38 (patch) | |
| tree | 258e0aae8fdbdce64d8df36e75138a186358cd6b /src/config.c | |
basic backup system, which utlizies regex for ignore files
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c new file mode 100644 index 0000000..ab0eb05 --- /dev/null +++ b/src/config.c @@ -0,0 +1,24 @@ +#include "lib.h" +#include <stdio.h> +#include <stdlib.h> + +char config[PATH_MAX] = {0}; +char* get_default_config() { + if (config[0] != 0) return config; + + const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); + const char* home = getenv("HOME"); + + if (home == NULL) { + fprintf(stderr, "HOME environment variable not set, failed to determine the config path"); + return NULL; + } + + if (xdg_config_home != NULL && xdg_config_home[0] != 0) { + snprintf(config, PATH_MAX, "%s/backbencher/.backupignore", xdg_config_home); + } else { + snprintf(config, PATH_MAX, "%s/.config/backbencher/.backupignore", home); + } + + return config; +} |
