From 6684a8280f41d7ca2684b386b2c70d5454a3ac62 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 17 Jan 2022 21:48:35 -0800 Subject: [PATCH] AdPlug: Plugin now loads its AdPlug database on startup --- Plugins/AdPlug/AdPlug/AdPlugDecoder.mm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm b/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm index 10e041cac..df0139c97 100755 --- a/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm +++ b/Plugins/AdPlug/AdPlug/AdPlugDecoder.mm @@ -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];