mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Deduplicate executable path computation
This commit is contained in:
parent
22235226d6
commit
32f13c3716
3 changed files with 9 additions and 15 deletions
|
@ -441,17 +441,6 @@ bool Launcher::customWorkingDir() const {
|
||||||
void Launcher::prepareSettings() {
|
void Launcher::prepareSettings() {
|
||||||
auto path = base::Platform::CurrentExecutablePath(_argc, _argv);
|
auto path = base::Platform::CurrentExecutablePath(_argc, _argv);
|
||||||
LOG(("Executable path before check: %1").arg(path));
|
LOG(("Executable path before check: %1").arg(path));
|
||||||
if (!path.isEmpty()) {
|
|
||||||
auto info = QFileInfo(path);
|
|
||||||
if (info.isSymLink()) {
|
|
||||||
info = QFileInfo(info.symLinkTarget());
|
|
||||||
}
|
|
||||||
if (info.exists()) {
|
|
||||||
const auto dir = info.absoluteDir().absolutePath();
|
|
||||||
gExeDir = (dir.endsWith('/') ? dir : (dir + '/'));
|
|
||||||
gExeName = info.fileName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cExeName().isEmpty()) {
|
if (cExeName().isEmpty()) {
|
||||||
LOG(("WARNING: Could not compute executable path, some features will be disabled."));
|
LOG(("WARNING: Could not compute executable path, some features will be disabled."));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ QByteArray gAlphaPrivateKey;
|
||||||
|
|
||||||
bool gManyInstance = false;
|
bool gManyInstance = false;
|
||||||
QString gKeyFile;
|
QString gKeyFile;
|
||||||
QString gWorkingDir, gExeDir, gExeName;
|
QString gWorkingDir;
|
||||||
|
|
||||||
QStringList gSendPaths;
|
QStringList gSendPaths;
|
||||||
QString gStartUrl;
|
QString gStartUrl;
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/integration.h"
|
||||||
#include "ui/style/style_core.h"
|
#include "ui/style/style_core.h"
|
||||||
|
|
||||||
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
|
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
|
||||||
|
@ -56,11 +57,15 @@ inline void cForceWorkingDir(const QString &newDir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
DeclareReadSetting(QString, ExeName);
|
inline QString cExeName() {
|
||||||
DeclareReadSetting(QString, ExeDir);
|
return base::Integration::Instance().executableName();
|
||||||
|
}
|
||||||
|
inline QString cExeDir() {
|
||||||
|
return base::Integration::Instance().executableDir();
|
||||||
|
}
|
||||||
DeclareSetting(QString, DialogLastPath);
|
DeclareSetting(QString, DialogLastPath);
|
||||||
DeclareSetting(QString, DialogHelperPath);
|
DeclareSetting(QString, DialogHelperPath);
|
||||||
inline const QString &cDialogHelperPathFinal() {
|
inline QString cDialogHelperPathFinal() {
|
||||||
return cDialogHelperPath().isEmpty() ? cExeDir() : cDialogHelperPath();
|
return cDialogHelperPath().isEmpty() ? cExeDir() : cDialogHelperPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue