static std::string resolvePath(const boost::filesystem::path & base_path, std::string && path) { boost::filesystem::path resolved_path(path); if (!resolved_path.is_absolute()) return (base_path / resolved_path).string(); return resolved_path.string(); }
std::string our_exe_path () { if (argv0[0] == '/') { // argv[0] starts with / => it's an absolute path return argv0; } else if (std::strchr(argv0, '/')) { // argv[0] contains / => it a relative path that should be resolved char* resolved_path_p = realpath(argv0, NULL); std::string resolved_path(resolved_path_p); free(resolved_path_p); return resolved_path; } else { // argv[0] is just a bare filename => not much we can do return argv0; } }