mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Platform (Windows): add exePath
This commit is contained in:
@@ -8,6 +8,7 @@ void ffPlatformInit(FFPlatform* platform)
|
||||
ffStrbufInit(&platform->cacheDir);
|
||||
ffListInit(&platform->configDirs, sizeof(FFstrbuf));
|
||||
ffListInit(&platform->dataDirs, sizeof(FFstrbuf));
|
||||
ffStrbufInit(&platform->exePath);
|
||||
|
||||
ffStrbufInit(&platform->userName);
|
||||
ffStrbufInit(&platform->hostName);
|
||||
|
||||
@@ -11,6 +11,7 @@ typedef struct FFPlatform {
|
||||
FFstrbuf cacheDir; // Trailing slash included
|
||||
FFlist configDirs; // List of FFstrbuf, trailing slash included
|
||||
FFlist dataDirs; // List of FFstrbuf, trailing slash included
|
||||
FFstrbuf exePath; // The real path of current exe
|
||||
|
||||
FFstrbuf userName;
|
||||
FFstrbuf hostName;
|
||||
|
||||
@@ -6,6 +6,18 @@
|
||||
#include <Windows.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
static void getExePath(FFPlatform* platform)
|
||||
{
|
||||
wchar_t exePathW[MAX_PATH];
|
||||
DWORD exePathWLen = GetModuleFileNameW(NULL, exePathW, MAX_PATH);
|
||||
if (exePathWLen == 0 && exePathWLen >= MAX_PATH) return;
|
||||
|
||||
ffStrbufSetNWS(&platform->exePath, exePathWLen, exePathW);
|
||||
if (ffStrbufStartsWithS(&platform->exePath, "\\\\?\\"))
|
||||
ffStrbufSubstrAfter(&platform->exePath, 3);
|
||||
ffStrbufReplaceAllC(&platform->exePath, '\\', '/');
|
||||
}
|
||||
|
||||
static void getHomeDir(FFPlatform* platform)
|
||||
{
|
||||
PWSTR pPath;
|
||||
@@ -213,6 +225,7 @@ static void getSystemArchitecture(FFPlatform* platform)
|
||||
|
||||
void ffPlatformInitImpl(FFPlatform* platform)
|
||||
{
|
||||
getExePath(platform);
|
||||
getHomeDir(platform);
|
||||
getCacheDir(platform);
|
||||
getConfigDirs(platform);
|
||||
|
||||
Reference in New Issue
Block a user