mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-22 15:38:33 +00:00
create data path and config path on ios if they do not exist
This commit is contained in:
parent
20f8fe59a4
commit
a859c185b5
1 changed files with 23 additions and 0 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
#import "linphone/utils/utils.h"
|
#import "linphone/utils/utils.h"
|
||||||
|
|
||||||
#import "core/platform-helpers/platform-helpers.h"
|
#import "core/platform-helpers/platform-helpers.h"
|
||||||
|
#import "logger/logger.h"
|
||||||
#import "paths-apple.h"
|
#import "paths-apple.h"
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
@ -32,6 +33,17 @@ std::string SysPaths::getDataPath (PlatformHelpers *platformHelper) {
|
||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||||
NSString *writablePath = [paths objectAtIndex:0];
|
NSString *writablePath = [paths objectAtIndex:0];
|
||||||
NSString *fullPath = [writablePath stringByAppendingString:@"/linphone/"];
|
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;
|
const char *ret = fullPath.UTF8String;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +52,17 @@ std::string SysPaths::getConfigPath (PlatformHelpers *platformHelper) {
|
||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
|
||||||
NSString *configPath = [paths objectAtIndex:0];
|
NSString *configPath = [paths objectAtIndex:0];
|
||||||
NSString *fullPath = [configPath stringByAppendingString:@"/Preferences/linphone/"];
|
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;
|
const char *ret = fullPath.UTF8String;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue