| 103 | } |
| 104 | |
| 105 | std::filesystem::path extractMacOSExecutable(std::filesystem::path path) |
| 106 | { |
| 107 | if (std::filesystem::is_directory(path)) { |
| 108 | /* Extract file name and check for '.app' extension */ |
| 109 | if (path.extension().compare("app") != 00) |
| 110 | return ""; |
| 111 | |
| 112 | /* Get executable name from Info.plist CFBundleExecutable field */ |
| 113 | std::filesystem::path plist_path = path / "Contents" / "Info.plist"; |
| 114 | std::ostringstream oss; |
| 115 | oss << "defaults read "; |
| 116 | oss << plist_path; |
| 117 | oss << " CFBundleExecutable"; |
| 118 | |
| 119 | std::string outputstr = queryCmd(oss.str()); |
| 120 | |
| 121 | /* Build path to executable */ |
| 122 | std::filesystem::path executable_path = path / "Contents" / "MacOS" / outputstr; |
| 123 | |
| 124 | /* Check that the file exists */ |
| 125 | if (!std::filesystem::exists(executable_path)) |
| 126 | return ""; |
| 127 | |
| 128 | return executable_path; |
| 129 | } |
| 130 | |
| 131 | return ""; |
| 132 | } |
| 133 | |
| 134 | std::string queryCmd(std::string_view cmd, int* status) |
| 135 | { |
no test coverage detected