libobs: Use proper resource paths when running from an OSX bundle

This commit is contained in:
Colin Edwards
2019-10-13 21:46:08 -05:00
parent 6b08c064f6
commit 747ce9b77c
3 changed files with 62 additions and 5 deletions

View File

@@ -28,11 +28,27 @@
using namespace std;
bool isInBundle()
{
NSRunningApplication *app = [NSRunningApplication currentApplication];
return [app bundleIdentifier] != nil;
}
bool GetDataFilePath(const char *data, string &output)
{
stringstream str;
str << OBS_DATA_PATH "/obs-studio/" << data;
output = str.str();
if (isInBundle()) {
NSBundle *myBundle = [NSBundle mainBundle];
NSString *path = [NSString
stringWithFormat:@"data/obs-studio/%@",
[NSString stringWithUTF8String:data]];
NSString *absPath = [myBundle pathForResource:path ofType:nil];
output = [absPath UTF8String];
} else {
stringstream str;
str << OBS_DATA_PATH "/obs-studio/" << data;
output = str.str();
}
return !access(output.c_str(), R_OK);
}