get current executable's directory
| 22 | |
| 23 | // get current executable's directory |
| 24 | std::string get_current_dir() { |
| 25 | char buf[1024]; |
| 26 | int dirfd = open("/proc/self/", O_RDONLY | O_DIRECTORY); |
| 27 | if (dirfd == -1) { |
| 28 | // Handle error |
| 29 | } |
| 30 | |
| 31 | ssize_t len = readlinkat(dirfd, "exe", buf, sizeof(buf) - 1); |
| 32 | if (len == -1) { |
| 33 | // Handle error |
| 34 | } |
| 35 | buf[len] = '\0'; |
| 36 | close(dirfd); |
| 37 | std::string exe_path(buf); |
| 38 | return exe_path.substr(0, exe_path.rfind('/')); |
| 39 | } |
| 40 | |
| 41 | std::string find_codegen_bin() { |
| 42 | // first check whether flex_home env exists |
no test coverage detected