Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 38 additions & 27 deletions backends/apple/coreml/runtime/delegate/ETCoreMLStrings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,50 @@ + (NSString *)debugSymbolToHandlesKeyName {
}

+ (nullable NSString *)assetsDirectoryPath {
static dispatch_once_t onceToken;
static NSString *result = nil;
dispatch_once(&onceToken, ^{
NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
if (paths.count > 0) {
result = [paths.lastObject stringByAppendingPathComponent:self.productName];
}
});

return result;
#if defined(EXECUTORCH_COREML_ASSETS_DIRECTORY_PATH)
return @(EXECUTORCH_COREML_ASSETS_DIRECTORY_PATH);
#else
static dispatch_once_t onceToken;
static NSString *result = nil;
dispatch_once(&onceToken, ^{
NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
if (paths.count > 0) {
result = [paths.lastObject stringByAppendingPathComponent:self.productName];
}
});

return result;
#endif
}

+ (nullable NSString *)trashDirectoryPath {
static dispatch_once_t onceToken;
static NSString *result = nil;
dispatch_once(&onceToken, ^{
result = [NSTemporaryDirectory() stringByAppendingPathComponent:self.productName];
});

return result;
#if defined(EXECUTORCH_COREML_TRASH_DIRECTORY_PATH)
return @(EXECUTORCH_COREML_TRASH_DIRECTORY_PATH);
#else
static dispatch_once_t onceToken;
static NSString *result = nil;
dispatch_once(&onceToken, ^{
result = [NSTemporaryDirectory() stringByAppendingPathComponent:self.productName];
});

return result;
#endif
}

+ (nullable NSString *)databaseDirectoryPath {
static dispatch_once_t onceToken;
static NSString *result = nil;
dispatch_once(&onceToken, ^{
NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
if (paths.count > 0) {
result = [paths.lastObject stringByAppendingPathComponent:self.productName];
}
});

return result;
#if defined(EXECUTORCH_COREML_DATABASE_DIRECTORY_PATH)
return @(EXECUTORCH_COREML_DATABASE_DIRECTORY_PATH);
#else
static dispatch_once_t onceToken;
static NSString *result = nil;
dispatch_once(&onceToken, ^{
NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
if (paths.count > 0) {
result = [paths.lastObject stringByAppendingPathComponent:self.productName];
}
});
return result;
#endif
}


Expand Down