mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-31 10:20:13 +00:00
Merge branch 'fix_mac_os_current_path' into 'master'
Set MacOS current_path before reading configuration files [#7706] See merge request OpenMW/openmw!3739
This commit is contained in:
commit
e6e24e1b6c
@ -245,6 +245,7 @@ Programmers
|
|||||||
xyzz
|
xyzz
|
||||||
Yohaulticetl
|
Yohaulticetl
|
||||||
Yuri Krupenin
|
Yuri Krupenin
|
||||||
|
Yury Stepovikov
|
||||||
zelurker
|
zelurker
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
|
@ -41,11 +41,6 @@ int runLauncher(int argc, char* argv[])
|
|||||||
appTranslator.load(":/translations/" + locale + ".qm");
|
appTranslator.load(":/translations/" + locale + ".qm");
|
||||||
app.installTranslator(&appTranslator);
|
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::MainDialog mainWin(configurationManager);
|
||||||
|
|
||||||
Launcher::FirstRunDialogResult result = mainWin.showFirstRunDialog();
|
Launcher::FirstRunDialogResult result = mainWin.showFirstRunDialog();
|
||||||
|
@ -81,11 +81,6 @@ int runApplication(int argc, char* argv[])
|
|||||||
|
|
||||||
Application application(argc, argv);
|
Application application(argc, argv);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
QDir dir(QCoreApplication::applicationDirPath());
|
|
||||||
QDir::setCurrent(dir.absolutePath());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
application.setWindowIcon(QIcon(":./openmw-cs.png"));
|
application.setWindowIcon(QIcon(":./openmw-cs.png"));
|
||||||
|
|
||||||
CS::Editor editor(argc, argv);
|
CS::Editor editor(argc, argv);
|
||||||
|
@ -219,8 +219,6 @@ int runApplication(int argc, char* argv[])
|
|||||||
Platform::init();
|
Platform::init();
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#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);
|
setenv("OSG_GL_TEXTURE_STORAGE", "OFF", 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@ int main(int argc, char* argv[])
|
|||||||
app.setLibraryPaths(libraryPaths);
|
app.setLibraryPaths(libraryPaths);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QDir::setCurrent(dir.absolutePath());
|
|
||||||
|
|
||||||
Wizard::MainWizard wizard;
|
Wizard::MainWizard wizard;
|
||||||
|
|
||||||
wizard.show();
|
wizard.show();
|
||||||
|
@ -5,13 +5,41 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/misc/strings/lower.hpp>
|
#include <components/misc/strings/lower.hpp>
|
||||||
|
|
||||||
namespace
|
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()
|
std::filesystem::path getUserHome()
|
||||||
{
|
{
|
||||||
const char* dir = getenv("HOME");
|
const char* dir = getenv("HOME");
|
||||||
@ -36,6 +64,11 @@ namespace Files
|
|||||||
MacOsPath::MacOsPath(const std::string& application_name)
|
MacOsPath::MacOsPath(const std::string& application_name)
|
||||||
: mName(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
|
std::filesystem::path MacOsPath::getUserConfigPath() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user