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

@@ -4,6 +4,7 @@
#ifdef __APPLE__
#include <Foundation/Foundation.h>
#include "objc_utils.h"
#endif
#ifdef __ANDROID__
@@ -141,6 +142,8 @@ bool Asset::create_dir(const std::string& path)
return PathFileExistsA(path.c_str()) ? true : CreateDirectoryA(path.c_str(), NULL);
#elif __ANDROID__
return android_create_dir(path);
#elif __IOS__ || __OSX__
return apple_create_dir(path);
#endif
}

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;
}

View File

@@ -15,3 +15,4 @@ void uinstall_global_handlers();
void delete_all_files_in_path(const std::string& source_path);
void export_mp4(const std::string& rec_path, int width, int height, int tot, void(^progress_callback)(float));
void save_image_library(const std::string& path);
bool apple_create_dir(const std::string& path);