From a859c185b5345cc4e05a4e7c4c3367cea5241a72 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 27 Oct 2017 15:54:43 +0200 Subject: [PATCH] create data path and config path on ios if they do not exist --- src/core/paths/paths-apple.mm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/core/paths/paths-apple.mm b/src/core/paths/paths-apple.mm index 55b35e59b..75ecebe91 100644 --- a/src/core/paths/paths-apple.mm +++ b/src/core/paths/paths-apple.mm @@ -20,6 +20,7 @@ #import "linphone/utils/utils.h" #import "core/platform-helpers/platform-helpers.h" +#import "logger/logger.h" #import "paths-apple.h" #import @@ -32,6 +33,17 @@ std::string SysPaths::getDataPath (PlatformHelpers *platformHelper) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *writablePath = [paths objectAtIndex:0]; NSString *fullPath = [writablePath stringByAppendingString:@"/linphone/"]; + if(![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) { + NSError *error; + lInfo() << "Data path " << fullPath.UTF8String << " does not exist, creating it."; + if (![[NSFileManager defaultManager] createDirectoryAtPath:fullPath + withIntermediateDirectories:YES + attributes:nil + error:&error]) { + lError() << "Create data path directory error: " << error.description; + } + } + const char *ret = fullPath.UTF8String; return ret; } @@ -40,6 +52,17 @@ std::string SysPaths::getConfigPath (PlatformHelpers *platformHelper) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *configPath = [paths objectAtIndex:0]; NSString *fullPath = [configPath stringByAppendingString:@"/Preferences/linphone/"]; + if(![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) { + NSError *error; + lInfo() << "Config path " << fullPath.UTF8String << " does not exist, creating it."; + if (![[NSFileManager defaultManager] createDirectoryAtPath:fullPath + withIntermediateDirectories:YES + attributes:nil + error:&error]) { + lError() << "Create config path directory error: " << error.description; + } + } + const char *ret = fullPath.UTF8String; return ret; }