AdPlug: Plugin now loads its AdPlug database on startup

CQTexperiment
Christopher Snowhill 2022-01-17 21:48:35 -08:00
parent 322d9539d6
commit 6684a8280f
1 changed files with 23 additions and 0 deletions

View File

@ -18,6 +18,29 @@
@implementation AdPlugDecoder
static CAdPlugDatabase * g_database = NULL;
+ (void)initialize
{
if (!g_database) {
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetBundleWithIdentifier(CFSTR("net.kode54.AdPlug")), CFSTR("adplug"), CFSTR("db"), NULL);
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
NSString *dbPath = (__bridge NSString *) macPath;
if (dbPath) {
g_database = new CAdPlugDatabase;
g_database->load([dbPath UTF8String]);
CAdPlug::set_database( g_database );
CFRelease(macPath);
CFRelease(appUrlRef);
}
}
}
- (id)init
{
self = [super init];