MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / Path_GetExecutablePath

Function Path_GetExecutablePath

samples/shared/pathtools.cpp:33–72  ·  view source on GitHub ↗

Returns the path (including filename) to the current executable */

Source from the content-addressed store, hash-verified

31
32/** Returns the path (including filename) to the current executable */
33std::string Path_GetExecutablePath()
34{
35#if defined( _WIN32 )
36 wchar_t *pwchPath = new wchar_t[MAX_UNICODE_PATH];
37 char *pchPath = new char[MAX_UNICODE_PATH_IN_UTF8];
38 ::GetModuleFileNameW( NULL, pwchPath, MAX_UNICODE_PATH );
39 WideCharToMultiByte( CP_UTF8, 0, pwchPath, -1, pchPath, MAX_UNICODE_PATH_IN_UTF8, NULL, NULL );
40 delete[] pwchPath;
41
42 std::string sPath = pchPath;
43 delete[] pchPath;
44 return sPath;
45#elif defined( OSX )
46 char rchPath[1024];
47 uint32_t nBuff = sizeof( rchPath );
48 bool bSuccess = _NSGetExecutablePath(rchPath, &nBuff) == 0;
49 rchPath[nBuff-1] = '\0';
50 if( bSuccess )
51 return rchPath;
52 else
53 return "";
54#elif defined LINUX
55 char rchPath[1024];
56 size_t nBuff = sizeof( rchPath );
57 ssize_t nRead = readlink("/proc/self/exe", rchPath, nBuff-1 );
58 if ( nRead != -1 )
59 {
60 rchPath[ nRead ] = 0;
61 return rchPath;
62 }
63 else
64 {
65 return "";
66 }
67#else
68 AssertMsg( false, "Implement Plat_GetExecutablePath" );
69 return "";
70#endif
71
72}
73
74/** Returns the path of the current working directory */
75std::string Path_GetWorkingDirectory()

Callers 6

CreateAllShadersMethod · 0.50
SetupTexturemapsMethod · 0.50
BInitMethod · 0.50
SetupTexturemapsMethod · 0.50
CreateAllShadersMethod · 0.50
SetupTexturemapsMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected