diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-11 22:05:00 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-11 22:05:00 +0100 |
| commit | 4fb67201414169a2687f41c4056b2e284b4938cb (patch) | |
| tree | a68246e3e21435229541f83f485ab41cfb2ba08a /old/2021-11-10-beforeremovingchecker/env.c | |
| parent | 3568412f8f230774d0d11d7ed1c897424f95d3ef (diff) | |
| download | nissy-4fb67201414169a2687f41c4056b2e284b4938cb.tar.gz nissy-4fb67201414169a2687f41c4056b2e284b4938cb.zip | |
Removed old files
Diffstat (limited to '')
| -rw-r--r-- | old/2021-11-10-beforeremovingchecker/env.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/old/2021-11-10-beforeremovingchecker/env.c b/old/2021-11-10-beforeremovingchecker/env.c deleted file mode 100644 index d13642f..0000000 --- a/old/2021-11-10-beforeremovingchecker/env.c +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | #include "env.h" | ||
| 2 | |||
| 3 | bool initialized_env = false; | ||
| 4 | char *tabledir; | ||
| 5 | |||
| 6 | void | ||
| 7 | init_env() | ||
| 8 | { | ||
| 9 | char *nissydata = getenv("NISSYDATA"); | ||
| 10 | char *localdata = getenv("XDG_DATA_HOME"); | ||
| 11 | char *home = getenv("HOME"); | ||
| 12 | bool read, write; | ||
| 13 | |||
| 14 | if (initialized_env) | ||
| 15 | return; | ||
| 16 | |||
| 17 | if (nissydata != NULL) { | ||
| 18 | tabledir = malloc(strlen(nissydata) * sizeof(char) + 20); | ||
| 19 | strcpy(tabledir, nissydata); | ||
| 20 | } else if (localdata != NULL) { | ||
| 21 | tabledir = malloc(strlen(localdata) * sizeof(char) + 20); | ||
| 22 | strcpy(tabledir, localdata); | ||
| 23 | strcat(tabledir, "/nissy"); | ||
| 24 | } else if (home != NULL) { | ||
| 25 | tabledir = malloc(strlen(home) * sizeof(char) + 20); | ||
| 26 | strcpy(tabledir, home); | ||
| 27 | strcat(tabledir, "/.nissy"); | ||
| 28 | } | ||
| 29 | |||
| 30 | mkdir(tabledir, 0777); | ||
| 31 | strcat(tabledir, "/tables"); | ||
| 32 | mkdir(tabledir, 0777); | ||
| 33 | |||
| 34 | read = !access(tabledir, R_OK); | ||
| 35 | write = !access(tabledir, W_OK); | ||
| 36 | |||
| 37 | if (!read) { | ||
| 38 | fprintf(stderr, "Table files cannot be read.\n"); | ||
| 39 | } else if (!write) { | ||
| 40 | fprintf(stderr, "Data directory not writable: "); | ||
| 41 | fprintf(stderr, "tables can be loaded, but not saved.\n"); | ||
| 42 | } | ||
| 43 | |||
| 44 | initialized_env = true; | ||
| 45 | } | ||
