mirror of
https://github.com/QuasarApp/CopyrightFixer.git
synced 2025-04-26 01:34:40 +00:00
ref #60 Added implementation for method checkSign.
This commit is contained in:
parent
357a7ab7b6
commit
3d370559fd
@ -16,35 +16,35 @@ bool IFileManager::isSupport(const Extension &curExt) const {
|
||||
|
||||
Extension IFileManager::toExtension(const QString &curExt) const {
|
||||
|
||||
if (".cpp" == curExt) {
|
||||
if ("cpp" == curExt) {
|
||||
return Extension::CPP;
|
||||
}
|
||||
|
||||
if (".hpp" == curExt) {
|
||||
if ("hpp" == curExt) {
|
||||
return Extension::HPP;
|
||||
}
|
||||
|
||||
if (".h" == curExt) {
|
||||
if ("h" == curExt) {
|
||||
return Extension::H;
|
||||
}
|
||||
|
||||
if (".cc" == curExt) {
|
||||
if ("cc" == curExt) {
|
||||
return Extension::CC;
|
||||
}
|
||||
|
||||
if (".qml" == curExt) {
|
||||
if ("qml" == curExt) {
|
||||
return Extension::QML;
|
||||
}
|
||||
|
||||
if (".pro" == curExt) {
|
||||
if ("pro" == curExt) {
|
||||
return Extension::PRO;
|
||||
}
|
||||
|
||||
if (".txt" == curExt) {
|
||||
if ("txt" == curExt) {
|
||||
return Extension::TXT;
|
||||
}
|
||||
|
||||
if (".py" == curExt) {
|
||||
if ("py" == curExt) {
|
||||
return Extension::PY;
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,55 @@
|
||||
|
||||
#include "signer.h"
|
||||
#include "CopyrighFixer/ifilemanager.h"
|
||||
#include <QDir>
|
||||
|
||||
namespace CopyrighFixer {
|
||||
Signer::Signer() {
|
||||
|
||||
}
|
||||
|
||||
bool Signer::checkSign(const Config &objConf) {
|
||||
bool Signer::checkSign(const Config &objConf) {
|
||||
|
||||
Config currConfig = objConf;
|
||||
|
||||
QDir currentFolder(currConfig.getSrcDir());
|
||||
currentFolder.setFilter(QDir::Dirs | QDir::Files);
|
||||
|
||||
QFileInfoList folderItems(currentFolder.entryInfoList());
|
||||
|
||||
for (auto i_file: folderItems) {
|
||||
|
||||
if (i_file.fileName() == "." || i_file.fileName() == "..") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!i_file.isDir()) {
|
||||
|
||||
IFileManager *currFM = searchFileByExt(i_file.suffix());
|
||||
Signature objSing = currConfig.getSignVal();
|
||||
|
||||
if (currFM == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool valRead = currFM->read(i_file.filePath(), objSing);
|
||||
if (!valRead) {
|
||||
return false;
|
||||
}
|
||||
|
||||
currConfig.setSingValue(objSing);
|
||||
|
||||
bool valWrite = currFM->write(i_file.filePath(), objSing);
|
||||
if (!valWrite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
currConfig.setSourceDir(i_file.filePath());
|
||||
checkSign(currConfig);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -25,7 +67,6 @@ IFileManager *Signer::searchFileByExt(const QString &extension) {
|
||||
return itemFM;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user