Contains three main changes: * In `Path::program()`, account for the macOS app bundle, so that portable config support works with the app bundle. * Create a new function `Path::resources()` for the resources path, since `Path::program()` can no longer trivially be used to construct the bundle resources path (no guarantee what the .app is named). On macOS this returns the path to "ares.app/Contents/Resources", on other platforms (in case they use it in the future) it just returns the same as `Path::program()`. * Fix an issue where, if Ares is stored in a sub-directory of the desktop, the path settings UI will display paths next to the program as relative to the desktop instead of relative to the program directory.
このコミットが含まれているのは:
コミット
d6b2ca53e2
|
@ -14,7 +14,7 @@ auto locate(const string& name) -> string {
|
|||
|
||||
// On macOS, also check the AppBundle Resource path
|
||||
#if defined(PLATFORM_MACOS)
|
||||
location = {Path::program(), "../Resources/", name};
|
||||
location = {Path::resources(), name};
|
||||
if(inode::exists(location)) return location;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -118,14 +118,14 @@ auto PathSettings::construct() -> void {
|
|||
auto PathSettings::refresh() -> void {
|
||||
//simplifies pathnames by abbreviating the home folder and trailing slash
|
||||
auto pathname = [](string name) -> string {
|
||||
if(name.beginsWith(Path::user())) {
|
||||
name.trimLeft(Path::user(), 1L);
|
||||
name.prepend("~/");
|
||||
}
|
||||
if(name.beginsWith(Path::program())) {
|
||||
name.trimLeft(Path::program(), 1L);
|
||||
name.prepend("./");
|
||||
}
|
||||
if(name.beginsWith(Path::user())) {
|
||||
name.trimLeft(Path::user(), 1L);
|
||||
name.prepend("~/");
|
||||
}
|
||||
if(name != "/") name.trimRight("/", 1L);
|
||||
return name;
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ auto locate(const string& name) -> string {
|
|||
|
||||
// On macOS, also check the AppBundle Resource path
|
||||
#if defined(PLATFORM_MACOS)
|
||||
location = {Path::program(), "../Resources/", name};
|
||||
location = {Path::resources(), name};
|
||||
if(inode::exists(location)) return location;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#include <shlobj.h>
|
||||
#elif defined(PLATFORM_MACOS)
|
||||
#include <CoreFoundation/CFBundle.h>
|
||||
#endif
|
||||
|
||||
namespace nall::Path {
|
||||
|
@ -14,12 +16,34 @@ NALL_HEADER_INLINE auto program() -> string {
|
|||
result.transform("\\", "/");
|
||||
return Path::real(result);
|
||||
#else
|
||||
#if defined(PLATFORM_MACOS)
|
||||
if (CFBundleRef bundle = CFBundleGetMainBundle()) {
|
||||
char path[PATH_MAX] = "";
|
||||
CFURLRef url = CFBundleCopyBundleURL(bundle);
|
||||
CFURLGetFileSystemRepresentation(url, true, reinterpret_cast<UInt8*>(path), sizeof(path));
|
||||
CFRelease(url);
|
||||
return Path::real(path);
|
||||
}
|
||||
#endif
|
||||
Dl_info info;
|
||||
dladdr((void*)&program, &info);
|
||||
return Path::real(info.dli_fname);
|
||||
#endif
|
||||
}
|
||||
|
||||
NALL_HEADER_INLINE auto resources() -> string {
|
||||
#if defined(PLATFORM_MACOS)
|
||||
if (CFBundleRef bundle = CFBundleGetMainBundle()) {
|
||||
char path[PATH_MAX] = "";
|
||||
CFURLRef url = CFBundleCopyBundleURL(bundle);
|
||||
CFURLGetFileSystemRepresentation(url, true, reinterpret_cast<UInt8*>(path), sizeof(path));
|
||||
CFRelease(url);
|
||||
return string(path).append("/Contents/Resources/");
|
||||
}
|
||||
#endif
|
||||
return program();
|
||||
}
|
||||
|
||||
NALL_HEADER_INLINE auto root() -> string {
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
wchar_t path[PATH_MAX] = L"";
|
||||
|
|
|
@ -26,6 +26,10 @@ inline auto real(string_view name) -> string {
|
|||
|
||||
auto program() -> string;
|
||||
|
||||
// program()
|
||||
// ./ares.app/Contents/Resources/
|
||||
auto resources() -> string;
|
||||
|
||||
// /
|
||||
// c:/
|
||||
auto root() -> string;
|
||||
|
|
読み込み中…
新しいイシューから参照