MCPcopy Create free account
hub / github.com/QNapi/qnapi / resolveP7zipPath

Method resolveP7zipPath

libqnapi/src/config/configreader.cpp:151–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151const GeneralConfig ConfigReader::resolveP7zipPath(
152 const GeneralConfig& config) const {
153 if (QFileInfo(config.p7zipPath()).isExecutable()) {
154 return config;
155 } else {
156 QString p7zipPath = "";
157
158#if defined(Q_OS_MAC)
159 p7zipPath =
160 QFileInfo(appExecutableDir + "/../Resources/7za").absoluteFilePath();
161#elif defined(Q_OS_WIN)
162 p7zipPath = QFileInfo(appExecutableDir + "/7za.exe").absoluteFilePath();
163#else
164 QString pathEnv =
165 QProcess::systemEnvironment().filter(QRegExp("^PATH=(.*)$")).value(0);
166 QStringList sysPaths = pathEnv.mid(5).split(":");
167 sysPaths.removeAll("");
168 sysPaths.append(".");
169
170 if (sysPaths.isEmpty()) {
171 sysPaths << "/bin"
172 << "/usr/bin"
173 << "/usr/local/bin";
174 }
175
176 sysPaths << appExecutableDir;
177
178 QStringList p7zipBinaries = {"7z", "7za"};
179
180 foreach (const QString sysPath, sysPaths) {
181 foreach (const QString p7zipBinary, p7zipBinaries) {
182 QFileInfo fi(sysPath + QDir::separator() + p7zipBinary);
183 if (fi.isExecutable()) {
184 p7zipPath = fi.absoluteFilePath();
185 break;
186 }
187 }
188
189 if (!p7zipPath.isEmpty()) {
190 break;
191 }
192 }
193
194 if (p7zipPath.isEmpty()) {
195 p7zipPath = "7z";
196 }
197#endif
198
199 return config.setP7zipPath(p7zipPath);
200 }
201}
202
203const GeneralConfig ConfigReader::resolveTmpPath(
204 const GeneralConfig& config) const {

Callers

nothing calls this directly

Calls 2

p7zipPathMethod · 0.80
setP7zipPathMethod · 0.80

Tested by

no test coverage detected