------------------------------------------------------------------------
| 90 | |
| 91 | //------------------------------------------------------------------------ |
| 92 | Optional<Path> getApplicationPath () |
| 93 | { |
| 94 | std::string appPath = ""; |
| 95 | |
| 96 | pid_t pid = getpid (); |
| 97 | char buf[10]; |
| 98 | sprintf (buf, "%d", pid); |
| 99 | std::string _link = "/proc/"; |
| 100 | _link.append (buf); |
| 101 | _link.append ("/exe"); |
| 102 | char proc[1024]; |
| 103 | int ch = readlink (_link.c_str (), proc, 1024); |
| 104 | if (ch == -1) |
| 105 | return {}; |
| 106 | |
| 107 | proc[ch] = 0; |
| 108 | appPath = proc; |
| 109 | std::string::size_type t = appPath.find_last_of ("/"); |
| 110 | appPath = appPath.substr (0, t); |
| 111 | |
| 112 | return Path {appPath}; |
| 113 | } |
| 114 | |
| 115 | //------------------------------------------------------------------------ |
| 116 | class LinuxModule : public Module |
no test coverage detected