add create directory api for iOS and macOS

This commit is contained in:
2019-09-17 11:09:26 +02:00
parent 6aa4339230
commit 882a516455
3 changed files with 18 additions and 0 deletions

View File

@@ -334,3 +334,17 @@ void save_image_library(const std::string& path)
}];
#endif
}
bool apple_create_dir(const std::string& path)
{
NSError* err = nil;
NSString* p = [NSString stringWithUTF8String:(path+"/").c_str()];
NSURL* url = [NSURL fileURLWithPath:p isDirectory:YES];
if (![[NSFileManager defaultManager] createDirectoryAtURL:url withIntermediateDirectories:YES attributes:nil error:&err])
{
LOG("error creating path: %s", path.c_str());
LOG("error creating path: %s", [[err description] cStringUsingEncoding:NSUTF8StringEncoding]);
return false;
}
return true;
}