MCPcopy Create free account
hub / github.com/IJHack/QtPass / initialiseEnvironment

Method initialiseEnvironment

src/util.cpp:41–68  ·  view source on GitHub ↗

* @brief Initializes the process environment and augments PATH with * platform-specific GPG locations. * @example * Util::initialiseEnvironment(); * * @note On macOS, appends common MacGPG2 and /usr/local/bin paths if available. * @note On Windows, appends common WinGPG and GnuPG installation paths if * available. */

Source from the content-addressed store, hash-verified

39 * available.
40 */
41void Util::initialiseEnvironment() {
42 if (!_envInitialised) {
43 _env = QProcessEnvironment::systemEnvironment();
44#ifdef __APPLE__
45 QString path = _env.value("PATH");
46 if (!path.contains("/usr/local/MacGPG2/bin") &&
47 QDir("/usr/local/MacGPG2/bin").exists())
48 path += ":/usr/local/MacGPG2/bin";
49 if (!path.contains("/usr/local/bin"))
50 path += ":/usr/local/bin";
51 _env.insert("PATH", path);
52#endif
53#ifdef Q_OS_WIN
54 QString path = _env.value("PATH");
55 if (!path.contains("C:\\Program Files\\WinGPG\\x86") &&
56 QDir("C:\\Program Files\\WinGPG\\x86").exists())
57 path += ";C:\\Program Files\\WinGPG\\x86";
58 if (!path.contains("C:\\Program Files\\GnuPG\\bin") &&
59 QDir("C:\\Program Files\\GnuPG\\bin").exists())
60 path += ";C:\\Program Files\\GnuPG\\bin";
61 _env.insert("PATH", path);
62#endif
63#ifdef QT_DEBUG
64 dbg() << _env.value("PATH");
65#endif
66 _envInitialised = true;
67 }
68}
69
70/**
71 * @brief Resolves the path to the password store directory.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected