diff options
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r-- | testing/toxic/main.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index ec439c84..cb0d9e19 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -3,11 +3,19 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <curses.h> | 5 | #include <curses.h> |
6 | #include <errno.h> | ||
6 | #include <stdio.h> | 7 | #include <stdio.h> |
7 | #include <stdlib.h> | 8 | #include <stdlib.h> |
8 | #include <stdbool.h> | 9 | #include <stdbool.h> |
9 | #include <stdint.h> | 10 | #include <stdint.h> |
10 | 11 | ||
12 | #ifdef _win32 | ||
13 | #include <direct.h> | ||
14 | #else | ||
15 | #include <sys/stat.h> | ||
16 | #include <sys/types.h> | ||
17 | #endif | ||
18 | |||
11 | #include "../../core/Messenger.h" | 19 | #include "../../core/Messenger.h" |
12 | #include "../../core/network.h" | 20 | #include "../../core/network.h" |
13 | 21 | ||
@@ -332,26 +340,19 @@ int main(int argc, char *argv[]) | |||
332 | { | 340 | { |
333 | int ch; | 341 | int ch; |
334 | int f_flag = 0; | 342 | int f_flag = 0; |
335 | char *configdir = get_user_config_dir(); | 343 | char *user_config_dir = get_user_config_dir(); |
336 | char *default_file = "data"; | ||
337 | int mkdir_err | ||
338 | #ifdef _win32 | ||
339 | mkdir_err = _mkdir(configdir); | ||
340 | #else | ||
341 | mkdir_err = mkdir(configdir, 0700); | ||
342 | #endif | ||
343 | |||
344 | char *filename; | 344 | char *filename; |
345 | if(mkdir_err == -1) { | 345 | int config_err = create_user_config_dir(user_config_dir); |
346 | filename = default_file; | 346 | if(config_err) { |
347 | filename = "data"; | ||
347 | } else { | 348 | } else { |
348 | filename = malloc(strlen(configdir) + strlen(default_file) + 1); | 349 | filename = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); |
349 | strcpy(filename, configdir); | 350 | strcpy(filename, user_config_dir); |
350 | strcat(filename, default_file); | 351 | strcat(filename, CONFIGDIR); |
352 | strcat(filename, "data"); | ||
351 | } | 353 | } |
352 | 354 | ||
353 | ToxWindow* a; | 355 | ToxWindow* a; |
354 | |||
355 | int i = 0; | 356 | int i = 0; |
356 | for (i = 0; i < argc; ++i) { | 357 | for (i = 0; i < argc; ++i) { |
357 | if (argv[i] == NULL) | 358 | if (argv[i] == NULL) |
@@ -378,6 +379,13 @@ int main(int argc, char *argv[]) | |||
378 | "defaulting to 'data' for a keyfile...\n"); | 379 | "defaulting to 'data' for a keyfile...\n"); |
379 | attroff(COLOR_PAIR(3) | A_BOLD); | 380 | attroff(COLOR_PAIR(3) | A_BOLD); |
380 | } | 381 | } |
382 | |||
383 | if(config_err) { | ||
384 | attron(COLOR_PAIR(3) | A_BOLD); | ||
385 | wprintw(prompt->window, "Unable to determine configuration directory!\n" | ||
386 | "defaulting to 'data' for a keyfile...\n"); | ||
387 | attroff(COLOR_PAIR(3) | A_BOLD); | ||
388 | } | ||
381 | 389 | ||
382 | while(true) { | 390 | while(true) { |
383 | /* Update tox */ | 391 | /* Update tox */ |