mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
libobs: Use proper resource paths when running from an OSX bundle
This commit is contained in:
parent
6b08c064f6
commit
747ce9b77c
@ -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);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ if(WIN32)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
set(libobs_PLATFORM_SOURCES
|
||||
obs-cocoa.c
|
||||
obs-cocoa.m
|
||||
util/threading-posix.c
|
||||
util/pipe-posix.c
|
||||
util/platform-nix.c
|
||||
|
@ -29,6 +29,14 @@
|
||||
#include <IOKit/hid/IOHIDDevice.h>
|
||||
#include <IOKit/hid/IOHIDManager.h>
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
bool is_in_bundle()
|
||||
{
|
||||
NSRunningApplication *app = [NSRunningApplication currentApplication];
|
||||
return [app bundleIdentifier] != nil;
|
||||
}
|
||||
|
||||
const char *get_module_extension(void)
|
||||
{
|
||||
return ".so";
|
||||
@ -51,12 +59,45 @@ void add_default_module_paths(void)
|
||||
{
|
||||
for (int i = 0; i < module_patterns_size; i++)
|
||||
obs_add_module_path(module_bin[i], module_data[i]);
|
||||
|
||||
if (is_in_bundle()) {
|
||||
NSRunningApplication *app =
|
||||
[NSRunningApplication currentApplication];
|
||||
NSURL *bundleURL = [app bundleURL];
|
||||
NSURL *pluginsURL = [bundleURL
|
||||
URLByAppendingPathComponent:@"Contents/Plugins"];
|
||||
NSURL *dataURL = [bundleURL
|
||||
URLByAppendingPathComponent:
|
||||
@"Contents/Resources/data/obs-plugins/%module%"];
|
||||
|
||||
const char *binPath = [[pluginsURL path]
|
||||
cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
const char *dataPath = [[dataURL path]
|
||||
cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
obs_add_module_path(binPath, dataPath);
|
||||
}
|
||||
}
|
||||
|
||||
char *find_libobs_data_file(const char *file)
|
||||
{
|
||||
struct dstr path;
|
||||
dstr_init_copy(&path, OBS_INSTALL_DATA_PATH "/libobs/");
|
||||
|
||||
if (is_in_bundle()) {
|
||||
NSRunningApplication *app =
|
||||
[NSRunningApplication currentApplication];
|
||||
NSURL *bundleURL = [app bundleURL];
|
||||
NSURL *libobsDataURL =
|
||||
[bundleURL URLByAppendingPathComponent:
|
||||
@"Contents/Resources/data/libobs/"];
|
||||
const char *libobsDataPath = [[libobsDataURL path]
|
||||
cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
dstr_init_copy(&path, libobsDataPath);
|
||||
dstr_cat(&path, "/");
|
||||
} else {
|
||||
dstr_init_copy(&path, OBS_INSTALL_DATA_PATH "/libobs/");
|
||||
}
|
||||
|
||||
dstr_cat(&path, file);
|
||||
return path.array;
|
||||
}
|
Loading…
Reference in New Issue
Block a user