////////////////////////////////////////////////////////////////////////// SetExeDir //////////////////////////////////////////////////////////////////////////
| 148 | // SetExeDir |
| 149 | /////////////////////////////////////////////////////////////////////////////// |
| 150 | static 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 | /////////////////////////////////////////////////////////////////////////////// |
no test coverage detected