mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +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() {
|
||||
auto path = base::Platform::CurrentExecutablePath(_argc, _argv);
|
||||
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()) {
|
||||
LOG(("WARNING: Could not compute executable path, some features will be disabled."));
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ QByteArray gAlphaPrivateKey;
|
|||
|
||||
bool gManyInstance = false;
|
||||
QString gKeyFile;
|
||||
QString gWorkingDir, gExeDir, gExeName;
|
||||
QString gWorkingDir;
|
||||
|
||||
QStringList gSendPaths;
|
||||
QString gStartUrl;
|
||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/integration.h"
|
||||
#include "ui/style/style_core.h"
|
||||
|
||||
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
|
||||
|
@ -56,11 +57,15 @@ inline void cForceWorkingDir(const QString &newDir) {
|
|||
}
|
||||
|
||||
}
|
||||
DeclareReadSetting(QString, ExeName);
|
||||
DeclareReadSetting(QString, ExeDir);
|
||||
inline QString cExeName() {
|
||||
return base::Integration::Instance().executableName();
|
||||
}
|
||||
inline QString cExeDir() {
|
||||
return base::Integration::Instance().executableDir();
|
||||
}
|
||||
DeclareSetting(QString, DialogLastPath);
|
||||
DeclareSetting(QString, DialogHelperPath);
|
||||
inline const QString &cDialogHelperPathFinal() {
|
||||
inline QString cDialogHelperPathFinal() {
|
||||
return cDialogHelperPath().isEmpty() ? cExeDir() : cDialogHelperPath();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue