mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-05-04 21:49:42 +00:00
fix app path on windows
This commit is contained in:
parent
a6f3f3dd79
commit
b87e4491cd
16
params.cpp
16
params.cpp
@ -9,6 +9,11 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include "windows.h"
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace QuasarAppUtils;
|
using namespace QuasarAppUtils;
|
||||||
|
|
||||||
@ -27,7 +32,18 @@ void Params::verboseLog(const QString &log) {
|
|||||||
|
|
||||||
bool Params::parseParams(int argc, char *argv[]) {
|
bool Params::parseParams(int argc, char *argv[]) {
|
||||||
params.clear();
|
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();
|
params ["appPath"] = QFileInfo(argv[0]).absolutePath();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!getStrArg("appPath").size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] == '-' && i ) {
|
if (argv[i][0] == '-' && i ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user