3 Star 0 Fork 1

hezitation/safety_center

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vsthread.cpp 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
CmeiLYL 提交于 2024-01-05 15:29 . sjh
// VSThread.cpp
#include "vsthread.h"
#include <QDebug>
VSThread::VSThread(const QString& cmd, const QStringList& args) : command(cmd), arguments(args)
{
}
void VSThread::run()
{
qDebug() << "Running command: " << command << " with arguments: " << arguments.join(" ");
// Create a process to run ClamAV
QProcess clamavProcess;
clamavProcess.start(command, arguments);
if (!clamavProcess.waitForStarted())
{
qDebug() << "Error starting ClamAV process.";
return;
}
QString infectedFilePath; // Variable to store infected file path
while (clamavProcess.waitForReadyRead())
{
QString output = clamavProcess.readAllStandardOutput();
QStringList lines = output.split('\n', Qt::SkipEmptyParts);
for (const QString& line : lines)
{
// Print ClamAV scan details
qDebug() << line;
emit outputUpdated(line);
// Check if the line indicates a virus detection
if (line.contains("FOUND"))
{
// Extract the infected file path
QStringList parts = line.split(' ', Qt::SkipEmptyParts);
if (parts.size() >= 3) // Make sure there are enough parts
{
infectedFilePath = parts[parts.size() - 2] + ' ' + parts[parts.size() - 1];
qDebug() << "Infected file found: " << infectedFilePath;
// emit outputUpdated(infectedFilePath);
}
else
{
qDebug() << "Error parsing infected file path.";
}
}
}
}
if (clamavProcess.exitCode() == 0)
{
qDebug() << "Scan completed. No viruses found.";
}
else
{
qDebug() << "Scan completed with errors. Exit code: " << clamavProcess.exitCode();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/hezitation/safety_center.git
git@gitee.com:hezitation/safety_center.git
hezitation
safety_center
safety_center
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385