* Get executable path. */
| 134 | * Get executable path. |
| 135 | */ |
| 136 | void 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. |