File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ void ffPlatformInit(FFPlatform* platform)
88 ffStrbufInit (& platform -> cacheDir );
99 ffListInit (& platform -> configDirs , sizeof (FFstrbuf ));
1010 ffListInit (& platform -> dataDirs , sizeof (FFstrbuf ));
11+ ffStrbufInit (& platform -> exePath );
1112
1213 ffStrbufInit (& platform -> userName );
1314 ffStrbufInit (& platform -> hostName );
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ typedef struct FFPlatform {
1111 FFstrbuf cacheDir ; // Trailing slash included
1212 FFlist configDirs ; // List of FFstrbuf, trailing slash included
1313 FFlist dataDirs ; // List of FFstrbuf, trailing slash included
14+ FFstrbuf exePath ; // The real path of current exe
1415
1516 FFstrbuf userName ;
1617 FFstrbuf hostName ;
Original file line number Diff line number Diff line change 66#include <Windows.h>
77#include <shlobj.h>
88
9+ static void getExePath (FFPlatform * platform )
10+ {
11+ wchar_t exePathW [MAX_PATH ];
12+ DWORD exePathWLen = GetModuleFileNameW (NULL , exePathW , MAX_PATH );
13+ if (exePathWLen == 0 && exePathWLen >= MAX_PATH ) return ;
14+
15+ ffStrbufSetNWS (& platform -> exePath , exePathWLen , exePathW );
16+ if (ffStrbufStartsWithS (& platform -> exePath , "\\\\?\\" ))
17+ ffStrbufSubstrAfter (& platform -> exePath , 3 );
18+ ffStrbufReplaceAllC (& platform -> exePath , '\\' , '/' );
19+ }
20+
921static void getHomeDir (FFPlatform * platform )
1022{
1123 PWSTR pPath ;
@@ -213,6 +225,7 @@ static void getSystemArchitecture(FFPlatform* platform)
213225
214226void ffPlatformInitImpl (FFPlatform * platform )
215227{
228+ getExePath (platform );
216229 getHomeDir (platform );
217230 getCacheDir (platform );
218231 getConfigDirs (platform );
You can’t perform that action at this time.
0 commit comments