added .config directory existence check

This commit is contained in:
Václav Šmejkal 2023-08-26 19:14:11 +02:00
parent b11f092bda
commit c0f7461eab
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 10 additions and 1 deletions

View File

@ -29,7 +29,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#define WHY2_INVALID_POINTER (void*) 0xffffffffffffffff
#define WHY2_CHAT_CONFIG_DIR "/home/{USER}/.config/WHY2"
#define WHY2_CONFIG_DIR "/home/{USER}/.config"
#define WHY2_CHAT_CONFIG_DIR WHY2_CONFIG_DIR "/WHY2"
#define WHY2_CHAT_CONFIG_URL "https://raw.githubusercontent.com/ENGO150/WHY2/development/src/chat/"
#define WHY2_CHAT_CONFIG_SERVER "server.yml"
#define WHY2_CHAT_CONFIG_CLIENT "client.yml"

View File

@ -34,6 +34,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
//LOCAL
void init_config(char *filename)
{
struct stat st;
//CREATE USER CONFIG FOLDER [THIS SHOULDN'T HAPPEN ON CLIENT, BUT IT'S NEEDED ON FRESH SERVERS]
if (stat(WHY2_CONFIG_DIR, &st) == -1)
{
mkdir(WHY2_CONFIG_DIR, 0700);
}
//GET THE CONFIG TYPE
char *buffer = why2_malloc(strlen(WHY2_CHAT_CONFIG_DIR) + strlen(filename) + 2);
sprintf(buffer, "%s/%s", WHY2_CHAT_CONFIG_DIR, filename);