Skip to content

Commit 4d08316

Browse files
committed
FileSystem: Add APPIMAGE Check Function
1 parent 8026e90 commit 4d08316

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

common/FileSystem.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,19 @@ std::string FileSystem::GetProgramPath()
25602560
#endif
25612561
}
25622562

2563+
std::string FileSystem::GetPackagePath()
2564+
{
2565+
// Check if we are running inside appimage. If so, return the path to the appimage instead.
2566+
if (const char* appimage_path = getenv("APPIMAGE"))
2567+
return std::string(appimage_path);
2568+
2569+
// TODO: Can probably be expanded to look for Flatpak too
2570+
2571+
// Otherwise, find the executable using `GetProgramPath()`
2572+
2573+
return GetProgramPath();
2574+
}
2575+
25632576
std::string FileSystem::GetWorkingDirectory()
25642577
{
25652578
std::string buffer;

common/FileSystem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ namespace FileSystem
169169
/// Returns the path to the current executable.
170170
std::string GetProgramPath();
171171

172+
173+
/// Returns the path to the current package (Linux AppImage).
174+
std::string GetPackagePath();
175+
172176
/// Retrieves the current working directory.
173177
std::string GetWorkingDirectory();
174178

0 commit comments

Comments
 (0)