Make sure our default path exists (for Linux and Mac)

I'm not sure if this could ever turn into an issue on Windows - but on
Linux and Mac this is an easy and safe thing to do and it avoids a
situation where we try to save the picture hashes without having this
directory.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-10-13 10:32:33 -07:00
parent ec8f2176a7
commit 50421f1fa8
2 changed files with 5 additions and 0 deletions

View file

@ -3,6 +3,7 @@
#include "dive.h"
#include "display.h"
#include "membuffer.h"
#include "qthelperfromc.h"
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
@ -63,6 +64,8 @@ static const char *system_default_path_append(const char *append)
memset(buffer, 0, len);
strcat(buffer, home);
strcat(buffer, path);
// make sure this path exists
subsurface_mkdir(buffer);
if (append) {
strcat(buffer, "/");
strcat(buffer, append);

View file

@ -56,6 +56,8 @@ static const char *system_default_path_append(const char *append)
memset(buffer, 0, len);
strcat(buffer, home);
strcat(buffer, path);
// make sure this path exists
subsurface_mkdir(buffer);
if (append) {
strcat(buffer, "/");
strcat(buffer, append);