4
0
mirror of https://github.com/QuasarApp/QuasarAppLib.git synced 2025-05-02 12:39:41 +00:00

fix app path on windows

This commit is contained in:
Andrei Yankovich 2019-01-27 19:45:30 +03:00
parent a6f3f3dd79
commit b87e4491cd

@ -9,6 +9,11 @@
#include <QVariantMap>
#include <QDebug>
#include <QFileInfo>
#ifdef Q_OS_WIN
#include "windows.h"
#else
#include <unistd.h>
#endif
using namespace QuasarAppUtils;
@ -27,7 +32,18 @@ void Params::verboseLog(const QString &log) {
bool Params::parseParams(int argc, char *argv[]) {
params.clear();
#ifdef Q_OS_WIN
char buffer[MAX_PATH];
GetModuleFileNameA(nullptr, buffer, MAX_PATH);
params ["appPath"] = QFileInfo(buffer).absolutePath();
#else
params ["appPath"] = QFileInfo(argv[0]).absolutePath();
#endif
if (!getStrArg("appPath").size()) {
return false;
}
for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-' && i ) {