1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-01 06:16:44 +02:00

better way to check if files exist

This commit is contained in:
Jfreegman
2014-08-27 22:45:11 -04:00
parent 155e194174
commit 511907fbc5
4 changed files with 22 additions and 18 deletions

View File

@ -29,6 +29,7 @@
#include "windows.h"
#include "configdir.h"
#include "notify.h"
#include "misc_tools.h"
#ifdef _AUDIO
#include "device.h"
@ -222,13 +223,14 @@ int settings_load(struct user_settings *s, const char *patharg)
free(user_config_dir);
/* make sure path exists or is created on first time running */
FILE *fp = fopen(path, "r");
if (fp == NULL) {
if ((fp = fopen(path, "w")) == NULL)
return -1;
}
if (!file_exists(path)) {
FILE *fp = fopen(path, "w");
fclose(fp);
if (fp == NULL)
return -1;
fclose(fp);
}
} else {
snprintf(path, sizeof(path), "%s", patharg);
}