fixed .config directory path

This commit is contained in:
Václav Šmejkal 2023-08-27 11:05:11 +02:00
parent c0f7461eab
commit 15bc846db8
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -35,15 +35,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
void init_config(char *filename) void init_config(char *filename)
{ {
struct stat st; 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(WHY2_CONFIG_DIR, &st) == -1) if (stat(buffer, &st) == -1)
{ {
mkdir(WHY2_CONFIG_DIR, 0700); mkdir(buffer, 0700);
} }
//GET THE CONFIG TYPE //GET THE CONFIG TYPE
char *buffer = why2_malloc(strlen(WHY2_CHAT_CONFIG_DIR) + strlen(filename) + 2); buffer = why2_realloc(buffer, 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"));