added .config directory existence check
This commit is contained in:
parent
b11f092bda
commit
c0f7461eab
@ -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"
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user