fix(ios): outputPath on iOS can contain an absolute path

This commit is contained in:
Umberto Lentini 2017-09-27 10:31:25 +02:00 committed by Antoine Doubovetzky
parent 16505b771e
commit 3458ffedad

View File

@ -42,7 +42,12 @@ NSString * generateFilePath(NSString * ext, NSString * outputPath)
} else {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
directory = [documentsDirectory stringByAppendingPathComponent:outputPath];
if ([outputPath hasPrefix:documentsDirectory]) {
directory = outputPath;
} else {
directory = [documentsDirectory stringByAppendingPathComponent:outputPath];
}
NSError *error;
[[NSFileManager defaultManager] createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:&error];
if (error) {