MCPcopy Create free account
hub / github.com/TASEmulators/fceux / _fceuExecutablePath

Function _fceuExecutablePath

src/drivers/Qt/ConsoleUtilities.cpp:239–296  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Returns the path of fceux.exe as a string.

Source from the content-addressed store, hash-verified

237//---------------------------------------------------------------------------
238// Returns the path of fceux.exe as a string.
239static int _fceuExecutablePath( std::string &outputPath )
240{
241 outputPath.clear();
242
243#ifdef WIN32
244 char fullPath[2048];
245 char driveLetter[3];
246 char directory[2048];
247 char finalPath[2048];
248
249 GetModuleFileNameA(NULL, fullPath, 2048);
250 _splitpath(fullPath, driveLetter, directory, NULL, NULL);
251 snprintf(finalPath, sizeof(finalPath), "%s%s", driveLetter, directory);
252 outputPath.assign( finalPath );
253
254 return 0;
255#elif __linux__ || __unix__
256 char exePath[ 2048 ];
257 ssize_t count = ::readlink( "/proc/self/exe", exePath, sizeof(exePath)-1 );
258
259 if ( count > 0 )
260 {
261 char *dir;
262 exePath[count] = 0;
263 //printf("EXE Path: '%s' \n", exePath );
264
265 dir = ::dirname( exePath );
266
267 if ( dir )
268 {
269 //printf("DIR Path: '%s' \n", dir );
270 outputPath.assign( dir );
271 return 0;
272 }
273 }
274#elif __APPLE__
275 char exePath[ 2048 ];
276 uint32_t bufSize = sizeof(exePath);
277 int result = _NSGetExecutablePath( exePath, &bufSize );
278
279 if ( result == 0 )
280 {
281 char *dir;
282 exePath[ sizeof(exePath)-1 ] = 0;
283 //printf("EXE Path: '%s' \n", exePath );
284
285 dir = ::dirname( exePath );
286
287 if ( dir )
288 {
289 //printf("DIR Path: '%s' \n", dir );
290 outputPath.assign( dir );
291 return 0;
292 }
293 }
294#endif
295 return -1;
296}

Callers 1

fceuExecutablePathFunction · 0.85

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected