pr fixes
This commit is contained in:
parent
5f584f747f
commit
ca843cb48b
|
@ -38,7 +38,7 @@ std::string default_realm_file_directory()
|
||||||
|
|
||||||
void ensure_directory_exists_for_file(const std::string &fileName)
|
void ensure_directory_exists_for_file(const std::string &fileName)
|
||||||
{
|
{
|
||||||
NSString *docsDir = [[NSString stringWithUTF8String:fileName.c_str()] stringByDeletingLastPathComponent];
|
NSString *docsDir = [@(fileName.c_str()) stringByDeletingLastPathComponent];
|
||||||
NSFileManager *manager = [NSFileManager defaultManager];
|
NSFileManager *manager = [NSFileManager defaultManager];
|
||||||
|
|
||||||
if (![manager fileExistsAtPath:docsDir]) {
|
if (![manager fileExistsAtPath:docsDir]) {
|
||||||
|
@ -50,16 +50,15 @@ void ensure_directory_exists_for_file(const std::string &fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remvoe_realm_files_from_directory(const std::string &directory)
|
void remove_realm_files_from_directory(const std::string &directory)
|
||||||
{
|
{
|
||||||
NSFileManager *manager = [NSFileManager defaultManager];
|
NSFileManager *manager = [NSFileManager defaultManager];
|
||||||
NSString *fileDir = @(directory.c_str());
|
NSString *fileDir = @(directory.c_str());
|
||||||
for (NSString *path in [manager enumeratorAtPath:fileDir]) {
|
for (NSString *path in [manager enumeratorAtPath:fileDir]) {
|
||||||
if (![manager removeItemAtPath:[fileDir stringByAppendingPathComponent:path] error:nil]) {
|
if (![manager removeItemAtPath:[fileDir stringByAppendingPathComponent:path] error:nil]) {
|
||||||
@throw [NSException exceptionWithName:@"removeItemAtPath error" reason:@"Failed to delete file" userInfo:nil];
|
throw std::runtime_error((std::string)"Failed to delete file at path " + path.UTF8String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ void RJSInitializeInContext(JSContextRef ctx) {
|
||||||
|
|
||||||
void RJSClearTestState() {
|
void RJSClearTestState() {
|
||||||
realm::Realm::s_global_cache.clear();
|
realm::Realm::s_global_cache.clear();
|
||||||
realm::remvoe_realm_files_from_directory(realm::default_realm_file_directory());
|
realm::remove_realm_files_from_directory(realm::default_realm_file_directory());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ std::string default_realm_file_directory();
|
||||||
void ensure_directory_exists_for_file(const std::string &file);
|
void ensure_directory_exists_for_file(const std::string &file);
|
||||||
|
|
||||||
// remoave all realm files in the given directory
|
// remoave all realm files in the given directory
|
||||||
void remvoe_realm_files_from_directory(const std::string &directory);
|
void remove_realm_files_from_directory(const std::string &directory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue