1/* 2 * Copyright (C) 2010-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9#import "tvosShared.h" 10 11#include "platform/darwin/ios-common/DarwinEmbedUtils.h" 12 13@implementation tvosShared 14 15+ (NSString*)getSharedID 16{ 17 return [@"group." stringByAppendingString:[self mainAppBundle].bundleIdentifier]; 18} 19 20+ (NSURL*)getSharedURL 21{ 22 NSString* sharedID = [self getSharedID]; 23 if (CDarwinEmbedUtils::IsIosSandboxed()) 24 { 25 NSFileManager* fileManager = [NSFileManager defaultManager]; 26 NSURL* sharedUrl = [fileManager containerURLForSecurityApplicationGroupIdentifier:sharedID]; 27 // e.g. /private/var/mobile/Containers/Shared/AppGroup/32B9DA1F-3B1F-4DBC-8326-ABB08BF16EC9/ 28 sharedUrl = [sharedUrl URLByAppendingPathComponent:@"Library" isDirectory:YES]; 29 sharedUrl = [sharedUrl URLByAppendingPathComponent:@"Caches" isDirectory:YES]; 30 return sharedUrl; 31 } 32 else 33 { 34 return [[NSURL fileURLWithPath:@"/var/mobile/Library/Caches"] 35 URLByAppendingPathComponent:sharedID]; 36 } 37} 38 39+ (NSBundle*)mainAppBundle 40{ 41 NSBundle* bundle = NSBundle.mainBundle; 42 if ([bundle.bundleURL.pathExtension isEqualToString:@"appex"]) 43 { // We're in a extension 44 // Peel off two directory levels - Kodi.app/PlugIns/MY_APP_EXTENSION.appex 45 bundle = [NSBundle bundleWithURL:bundle.bundleURL.URLByDeletingLastPathComponent 46 .URLByDeletingLastPathComponent]; 47 } 48 return bundle; 49} 50 51@end 52