mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 03:44:32 +01:00
Use a better default font path on Linux/Mac OS X.
This way people don't have to copy to ~/.ppsspp/flash0. The override in ~/.ppsspp/PSP/flash0 still works.
This commit is contained in:
1 parent
569f6132b9
commit
c486a09c2c
3 files changed
+52
-13
No files matched your search
+35
-9
@@ -215,6 +215,28 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string NativeProgramPath() {
|
||||
#if (defined(__APPLE__) && !defined(IOS)) || defined(__linux__)
|
||||
char program_path[4096];
|
||||
uint32_t program_path_size = sizeof(program_path) - 1;
|
||||
#if defined(__linux__)
|
||||
if (readlink("/proc/self/exe", program_path, 4095) > 0) {
|
||||
#elif defined(__APPLE__) && !defined(IOS)
|
||||
if (_NSGetExecutablePath(program_path, &program_path_size) == 0) {
|
||||
#else
|
||||
#error Unmatched ifdef.
|
||||
#endif
|
||||
program_path[sizeof(program_path) - 1] = '\0';
|
||||
char *last_slash = strrchr(program_path, '/');
|
||||
if (last_slash != NULL)
|
||||
*(last_slash + 1) = '\0';
|
||||
return program_path;
|
||||
}
|
||||
#endif
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void NativeInit(int argc, const char *argv[],
|
||||
const char *savegame_directory, const char *external_directory, const char *installID) {
|
||||
bool skipLogo = false;
|
||||
@@ -226,13 +248,11 @@ void NativeInit(int argc, const char *argv[],
|
||||
#ifdef IOS
|
||||
user_data_path += "/";
|
||||
#elif defined(__APPLE__)
|
||||
char program_path[4090];
|
||||
uint32_t program_path_size = sizeof(program_path);
|
||||
_NSGetExecutablePath(program_path,&program_path_size);
|
||||
*(strrchr(program_path, '/')+1) = '\0';
|
||||
char assets_path[4096];
|
||||
sprintf(assets_path,"%sassets/",program_path);
|
||||
VFSRegister("", new DirectoryAssetReader(assets_path));
|
||||
if (File::Exists(NativeProgramPath() + "assets"))
|
||||
VFSRegister("", new DirectoryAssetReader((NativeProgramPath() + "assets/").c_str()));
|
||||
// It's common to be in a build-xyz/ directory.
|
||||
else
|
||||
VFSRegister("", new DirectoryAssetReader((NativeProgramPath() + "../assets/").c_str()));
|
||||
#endif
|
||||
|
||||
// We want this to be FIRST.
|
||||
@@ -259,9 +279,15 @@ void NativeInit(int argc, const char *argv[],
|
||||
g_Config.memCardDirectory = user_data_path;
|
||||
g_Config.flash0Directory = std::string(external_directory) + "/flash0/";
|
||||
#elif !defined(_WIN32)
|
||||
// Linux, Mac. Does this path really make sense?
|
||||
g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
|
||||
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
|
||||
std::string program_path = NativeProgramPath();
|
||||
if (program_path.empty())
|
||||
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
|
||||
else if (File::Exists(program_path + "flash0"))
|
||||
g_Config.flash0Directory = program_path + "flash0/";
|
||||
// It's common to be in a build-xyz/ directory.
|
||||
else
|
||||
g_Config.flash0Directory = program_path + "../flash0/";
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
Reference in new issue
Block a user