MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / applicationFilePath

Method applicationFilePath

Global/ProcInfo.cpp:405–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403#endif // defined(__NATRON_OSX__)
404
405NATRON_NAMESPACE_ANONYMOUS_EXIT
406
407
408std::string
409ProcInfo::applicationFilePath(const char* argv0Param)
410{
411#if defined(__NATRON_WIN32__)
412 (void)argv0Param;
413
414 //The only viable solution
415 return applicationFileName();
416#elif defined(__NATRON_OSX__)
417 //First guess this way, then use the fallback solution
418 static std::string appFileName;
419
420 if ( appFileName.empty() ) {
421 NatronCFType<CFURLRef> bundleURL( CFBundleCopyExecutableURL( CFBundleGetMainBundle() ) );
422 if (bundleURL) {
423 NatronCFString cfPath( CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle) );
424 if (cfPath) {
425 appFileName = cfPath;
426 }
427 }
428 }
429 if ( !appFileName.empty() ) {
430 return appFileName;
431 } else {
432 return applicationFilePath_fromArgv(argv0Param);
433 }
434#elif defined(__NATRON_LINUX__)
435 // Try looking for a /proc/<pid>/exe symlink first which points to
436 // the absolute path of the executable
437 std::stringstream ss;
438 ss << "/proc/" << getpid() << "/exe";
439 std::string filename = ss.str();
440 char buf[2048] = {0};
441 ssize_t sizeofbuf = sizeof(char) * 2048;
442 ssize_t size = readlink(filename.c_str(), buf, sizeofbuf);
443 if ( (size != 0) && (size != sizeofbuf) ) {
444 //detected symlink
445 std::string ret(buf);
446 return ret;
447 } else {
448 return applicationFilePath_fromArgv(argv0Param);
449 }
450#endif
451}
452
453std::string
454ProcInfo::applicationDirPath(const char* argv0Param)

Callers 4

registerFileTypeMethod · 0.80
registerCommandMethod · 0.80
initInternalMethod · 0.80

Calls 3

applicationFileNameFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected