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:
Unknown W. Brackets 2013-10-20 22:14:15 -07:00
parent 569f6132b9
commit c486a09c2c
3 changed files with 52 additions and 13 deletions

View File

@ -3,6 +3,7 @@
#include <QFileInfo>
#include <QDebug>
#include <QDir>
#include <QCoreApplication>
#include "QtHost.h"
#include "LogManager.h"
@ -313,8 +314,19 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
g_Config.currentDirectory = QDir::homePath().toStdString();
}
g_Config.memCardDirectory = QDir::homePath().toStdString()+"/.ppsspp/";
g_Config.flash0Directory = g_Config.memCardDirectory+"/flash0/";
g_Config.memCardDirectory = QDir::homePath().toStdString() + "/.ppsspp/";
#if defined(Q_OS_LINUX) && !defined(ARM)
std::string program_path = QCoreApplication::applicationDirPath().toStdString();
if (File::Exists(program_path + "/flash0"))
g_Config.flash0Directory = program_path + "/flash0/";
else if (File::Exists(program_path + "/../flash0"))
g_Config.flash0Directory = program_path + "/../flash0/";
else
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
#else
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
#endif
LogManager::Init();
if (fileToLog != NULL)

View File

@ -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

View File

@ -329,8 +329,9 @@ int main(int argc, const char* argv[])
#if defined(ANDROID)
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__)
#elif !defined(_WIN32)
g_Config.memCardDirectory = std::string(getenv("HOME"))+"/.ppsspp/";
g_Config.flash0Directory = g_Config.memCardDirectory+"/flash/";
g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
// TODO: This isn't a great place.
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
#endif
if (screenshotFilename != 0)