MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / SetExeDir

Function SetExeDir

src/tw/twinit.cpp:150–178  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// SetExeDir //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

148// SetExeDir
149///////////////////////////////////////////////////////////////////////////////
150static bool SetExeDir(const TSTRING& strArgv0)
151{
152 ASSERT(!strArgv0.empty());
153
154 // record executable directory
155 TSTRING strFullPath;
156 if (iFSServices::GetInstance()->GetExecutableFilename(strFullPath, strArgv0) && !strFullPath.empty())
157 {
158#if USES_DEVICE_PATH
159 strFullPath = cDevicePath::AsPosix(strFullPath);
160#endif
161 cSystemInfo::SetExePath(strFullPath);
162
163 TSTRING::size_type s = strFullPath.find_last_of(_T('/'));
164 // paths will always come back from GetExecutableFilename delimited with a forward slash
165 ASSERT(TSTRING::npos != s);
166 if (TSTRING::npos != s)
167 strFullPath.resize(s);
168 cSystemInfo::SetExeDir(strFullPath);
169 }
170 else // error
171 {
172 ASSERT(false);
173 cSystemInfo::SetExeDir(_T(""));
174 return false;
175 }
176
177 return true;
178}
179
180
181///////////////////////////////////////////////////////////////////////////////

Callers 1

InitMethod · 0.85

Calls 3

emptyMethod · 0.80
GetExecutableFilenameMethod · 0.80
resizeMethod · 0.45

Tested by

no test coverage detected