MCPcopy Create free account
hub / github.com/GJDuck/e9patch / getExePath

Function getExePath

src/e9tool/e9misc.cpp:136–147  ·  view source on GitHub ↗

* Get executable path. */

Source from the content-addressed store, hash-verified

134 * Get executable path.
135 */
136void getExePath(std::string &path)
137{
138 char buf[BUFSIZ];
139 ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf)-1);
140 if (len < 0 || (size_t)len > sizeof(buf)-1)
141 error("failed to read executable path: %s", strerror(errno));
142 buf[len] = '\0';
143 char *dir = dirname(buf);
144 path += dir;
145 if (path.size() > 0 && path[path.size()-1] != '/')
146 path += '/';
147}
148
149/*
150 * Attempt to guess if the filename is a library or not.

Callers 1

main_2Function · 0.85

Calls 4

readlinkFunction · 0.85
errorFunction · 0.85
strerrorFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected