mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 21:35:24 +00:00
Set MacOS current_path before reading configuration files [#7706]
This commit is contained in:
parent
60d1262d61
commit
52623ddd7d
@ -245,6 +245,7 @@ Programmers
|
||||
xyzz
|
||||
Yohaulticetl
|
||||
Yuri Krupenin
|
||||
Yury Stepovikov
|
||||
zelurker
|
||||
|
||||
Documentation
|
||||
|
@ -41,11 +41,6 @@ int runLauncher(int argc, char* argv[])
|
||||
appTranslator.load(":/translations/" + locale + ".qm");
|
||||
app.installTranslator(&appTranslator);
|
||||
|
||||
// Now we make sure the current dir is set to application path
|
||||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
|
||||
QDir::setCurrent(dir.absolutePath());
|
||||
|
||||
Launcher::MainDialog mainWin(configurationManager);
|
||||
|
||||
Launcher::FirstRunDialogResult result = mainWin.showFirstRunDialog();
|
||||
|
@ -81,11 +81,6 @@ int runApplication(int argc, char* argv[])
|
||||
|
||||
Application application(argc, argv);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
QDir::setCurrent(dir.absolutePath());
|
||||
#endif
|
||||
|
||||
application.setWindowIcon(QIcon(":./openmw-cs.png"));
|
||||
|
||||
CS::Editor editor(argc, argv);
|
||||
|
@ -219,8 +219,6 @@ int runApplication(int argc, char* argv[])
|
||||
Platform::init();
|
||||
|
||||
#ifdef __APPLE__
|
||||
std::filesystem::path binary_path = std::filesystem::absolute(std::filesystem::path(argv[0]));
|
||||
std::filesystem::current_path(binary_path.parent_path());
|
||||
setenv("OSG_GL_TEXTURE_STORAGE", "OFF", 0);
|
||||
#endif
|
||||
|
||||
|
@ -28,8 +28,6 @@ int main(int argc, char* argv[])
|
||||
app.setLibraryPaths(libraryPaths);
|
||||
#endif
|
||||
|
||||
QDir::setCurrent(dir.absolutePath());
|
||||
|
||||
Wizard::MainWizard wizard;
|
||||
|
||||
wizard.show();
|
||||
|
@ -5,13 +5,41 @@
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::filesystem::path getBinaryPath()
|
||||
{
|
||||
uint32_t bufsize = 0;
|
||||
_NSGetExecutablePath(nullptr, &bufsize);
|
||||
|
||||
std::vector<char> buf(bufsize);
|
||||
|
||||
if (_NSGetExecutablePath(buf.data(), &bufsize) == 0)
|
||||
{
|
||||
std::filesystem::path path = std::filesystem::path(buf.begin(), buf.end());
|
||||
|
||||
if (std::filesystem::is_symlink(path))
|
||||
{
|
||||
return std::filesystem::read_symlink(path);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(Debug::Warning) << "Not enough buffer size to get executable path: " << bufsize;
|
||||
throw std::runtime_error("Failed to get executable path");
|
||||
}
|
||||
}
|
||||
|
||||
std::filesystem::path getUserHome()
|
||||
{
|
||||
const char* dir = getenv("HOME");
|
||||
@ -36,6 +64,11 @@ namespace Files
|
||||
MacOsPath::MacOsPath(const std::string& application_name)
|
||||
: mName(application_name)
|
||||
{
|
||||
std::filesystem::path binary_path = getBinaryPath();
|
||||
std::error_code ec;
|
||||
std::filesystem::current_path(binary_path.parent_path(), ec);
|
||||
if (ec.value() != 0)
|
||||
Log(Debug::Warning) << "Error " << ec.message() << " when changing current directory";
|
||||
}
|
||||
|
||||
std::filesystem::path MacOsPath::getUserConfigPath() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user