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

Method grepMatchFile

src/imitatepass.cpp:1044–1065  ·  view source on GitHub ↗

* @brief Decrypt one .gpg file and return lines matching rx. */

Source from the content-addressed store, hash-verified

1042 * @brief Decrypt one .gpg file and return lines matching rx.
1043 */
1044auto ImitatePass::grepMatchFile(const QStringList &env, const QString &gpgExe,
1045 const QString &filePath,
1046 const QRegularExpression &rx) -> QStringList {
1047 QString plaintext;
1048 const int rc =
1049 Executor::executeBlocking(env, gpgExe,
1050 {"-d", "--quiet", "--yes", "--no-encrypt-to",
1051 "--batch", "--use-agent", pgpg(filePath)},
1052 &plaintext);
1053 if (rc != 0 || plaintext.isEmpty())
1054 return {};
1055 QStringList matches;
1056 for (const QString &line : plaintext.split('\n')) {
1057 QString candidate = line;
1058 if (candidate.endsWith('\r'))
1059 candidate.chop(1);
1060 const QString t = candidate.trimmed();
1061 if (!t.isEmpty() && candidate.contains(rx))
1062 matches << t;
1063 }
1064 return matches;
1065}
1066
1067/**
1068 * @brief Walk the store, decrypt every .gpg file, collect matches.

Callers

nothing calls this directly

Calls 1

pgpgFunction · 0.85

Tested by

no test coverage detected