Skip to content

Commit 03a9326

Browse files
committed
Migrate some of Linux GlobalAutoPaths away from Qt.
1 parent afa8d82 commit 03a9326

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include "Common/Cpp/Filesystem/Filesystem.h"
1515
#include "GlobalAutoPaths.h"
1616

17+
#ifdef __linux__
18+
#include <cstdlib>
19+
#endif
20+
1721
//#include <iostream>
1822
//using std::cout;
1923
//using std::endl;
@@ -58,13 +62,17 @@ Filesystem::Path get_application_base_dir_path(){
5862
#if defined(__linux__)
5963
// Check for AppImage environment variables to find the root directory, if running as an AppImage.
6064
// PA_APPIMAGE_DIR is set by Azure via a patched AppRun script.
61-
QByteArray dir = qgetenv("PA_APPIMAGE_DIR");
62-
if (!dir.isEmpty()){
63-
return QString::fromUtf8(dir).toStdString();
65+
{
66+
char* dir = std::getenv("PA_APPIMAGE_DIR");
67+
if (dir != nullptr){
68+
return dir;
69+
}
6470
}
65-
QByteArray path = qgetenv("APPIMAGE");
66-
if (!path.isEmpty()){
67-
return QDir::cleanPath(QFileInfo(QString::fromUtf8(path)).dir().absolutePath()).toStdString();
71+
{
72+
char* path = std::getenv("APPIMAGE");
73+
if (path != nullptr){
74+
return std::filesystem::absolute(path).parent_path().lexically_normal();
75+
}
6876
}
6977
QByteArray appDirBytes = qgetenv("APPDIR");
7078
if (!appDirBytes.isEmpty()){

0 commit comments

Comments
 (0)