From c6818f812f9d764fe84e6dbca2ee203a203e85a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Sat, 13 Sep 2014 12:40:53 +0200 Subject: [PATCH] Create folder for save file if it does not exist. --- src/tox-weechat-identities.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tox-weechat-identities.c b/src/tox-weechat-identities.c index 106d27e..1935420 100644 --- a/src/tox-weechat-identities.c +++ b/src/tox-weechat-identities.c @@ -68,6 +68,11 @@ tox_weechat_save_identity_data_file(struct t_tox_weechat_identity *identity) { char *full_path = tox_weechat_identity_data_file_path(identity); + char *rightmost_slash = strrchr(full_path, '/'); + char *save_dir = strndup(full_path, rightmost_slash - full_path); + weechat_mkdir_parents(save_dir, 0755); + free(save_dir); + // save Tox data to a buffer uint32_t size = tox_size(identity->tox); uint8_t *data = malloc(sizeof(*data) * size);