MCPcopy Create free account
hub / github.com/clementgallet/libTAS / extractMacOSExecutable

Function extractMacOSExecutable

src/program/utils.cpp:105–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105std::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
134std::string queryCmd(std::string_view cmd, int* status)
135{

Callers 2

build_arg_listMethod · 0.85
extractBinaryTypeFunction · 0.85

Calls 1

queryCmdFunction · 0.85

Tested by

no test coverage detected