int main(const int argc, const char* argv[])
{
// Make sure we have a full path for argv[0].
- std::string argv0AbsolutePath;
std::string entryPointExecutablePath;
if (!GetEntrypointExecutableAbsolutePath(entryPointExecutablePath))
return -1;
}
- if (!GetAbsolutePath(entryPointExecutablePath.c_str(), argv0AbsolutePath))
- {
- perror("Could not normalize full path to current executable");
- return -1;
- }
-
// We will try to load the managed assembly with the same name as this executable
// but with the .dll extension.
- std::string programPath(argv0AbsolutePath);
+ std::string programPath(entryPointExecutablePath);
programPath.append(".dll");
const char* managedAssemblyAbsolutePath = programPath.c_str();
}
std::string clrFilesAbsolutePath;
- if(!GetClrFilesAbsolutePath(argv0AbsolutePath.c_str(), clrFilesPath, clrFilesAbsolutePath))
+ if(!GetClrFilesAbsolutePath(entryPointExecutablePath.c_str(), clrFilesPath, clrFilesAbsolutePath))
{
return -1;
}
int exitCode = ExecuteManagedAssembly(
- argv0AbsolutePath.c_str(),
+ entryPointExecutablePath.c_str(),
clrFilesAbsolutePath.c_str(),
managedAssemblyAbsolutePath,
managedAssemblyArgc,
// Make sure we have a full path for argv[0].
std::string argv0AbsolutePath;
- if (!GetAbsolutePath(argv[0], argv0AbsolutePath))
+ if (!GetEntrypointExecutableAbsolutePath(argv0AbsolutePath))
{
perror("Could not get full path");
return -1;
// Get path to the executable for the current process using
// platform specific means.
-#if defined(__linux__) || (defined(__NetBSD__) && !defined(KERN_PROC_PATHNAME))
- // On Linux, fetch the entry point EXE absolute path, inclusive of filename.
- char exe[PATH_MAX];
- ssize_t res = readlink(symlinkEntrypointExecutable, exe, PATH_MAX - 1);
- if (res != -1)
- {
- exe[res] = '\0';
- entrypointExecutable.assign(exe);
- result = true;
- }
- else
- {
- result = false;
- }
-#elif defined(__APPLE__)
+#if defined(__APPLE__)
// On Mac, we ask the OS for the absolute path to the entrypoint executable
uint32_t lenActualPath = 0;
result = false;
}
#else
- // On non-Mac OS, return the symlink that will be resolved by GetAbsolutePath
+ // On other OSs, return the symlink that will be resolved by GetAbsolutePath
// to fetch the entrypoint EXE absolute path, inclusive of filename.
- entrypointExecutable.assign(symlinkEntrypointExecutable);
- result = true;
+ result = GetAbsolutePath(symlinkEntrypointExecutable, entrypointExecutable);
#endif
return result;