moved why2_dir from init_config to why2_directory fn
This commit is contained in:
parent
db1d487a2e
commit
e802f5f483
@ -39,17 +39,11 @@ enum CONFIG_TYPES
|
|||||||
|
|
||||||
void init_config(char *filename)
|
void init_config(char *filename)
|
||||||
{
|
{
|
||||||
struct stat st;
|
|
||||||
char *buffer = why2_replace(WHY2_CONFIG_DIR, "{USER}", getenv("USER"));
|
|
||||||
|
|
||||||
//CREATE USER CONFIG FOLDER [THIS SHOULDN'T HAPPEN ON CLIENT, BUT IT'S NEEDED ON FRESH SERVERS]
|
//CREATE USER CONFIG FOLDER [THIS SHOULDN'T HAPPEN ON CLIENT, BUT IT'S NEEDED ON FRESH SERVERS]
|
||||||
if (stat(buffer, &st) == -1)
|
why2_directory();
|
||||||
{
|
|
||||||
mkdir(buffer, 0700);
|
|
||||||
}
|
|
||||||
|
|
||||||
//GET THE CONFIG TYPE
|
//GET THE CONFIG TYPE
|
||||||
buffer = why2_realloc(buffer, strlen(WHY2_CHAT_CONFIG_DIR) + strlen(filename) + 2);
|
char *buffer = why2_malloc(strlen(WHY2_CHAT_CONFIG_DIR) + strlen(filename) + 2);
|
||||||
sprintf(buffer, "%s/%s", WHY2_CHAT_CONFIG_DIR, filename);
|
sprintf(buffer, "%s/%s", WHY2_CHAT_CONFIG_DIR, filename);
|
||||||
|
|
||||||
char *path = why2_replace(buffer, "{USER}", getenv("USER"));
|
char *path = why2_replace(buffer, "{USER}", getenv("USER"));
|
||||||
|
@ -52,6 +52,21 @@ int removeDirectory(char *path)
|
|||||||
return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS);
|
return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void why2_directory(void)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
char *buffer = why2_replace(WHY2_CONFIG_DIR, "{USER}", getenv("USER"));
|
||||||
|
|
||||||
|
//CREATE USER CONFIG FOLDER
|
||||||
|
if (stat(buffer, &st) == -1)
|
||||||
|
{
|
||||||
|
mkdir(buffer, 0700);
|
||||||
|
}
|
||||||
|
|
||||||
|
//DEALLOCATION
|
||||||
|
why2_deallocate(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
enum WHY2_EXIT_CODES why2_check_version(void)
|
enum WHY2_EXIT_CODES why2_check_version(void)
|
||||||
{
|
{
|
||||||
if (why2_get_flags().no_check) return WHY2_SUCCESS;
|
if (why2_get_flags().no_check) return WHY2_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user