diff --git a/AboutDialog.cpp b/AboutDialog.cpp index c5cfd8d..9f93f74 100644 --- a/AboutDialog.cpp +++ b/AboutDialog.cpp @@ -20,7 +20,7 @@ // Project #include -const QString VERSION = QString("version 1.0.0"); +const QString VERSION = QString("version 1.0.1"); //----------------------------------------------------------------- AboutDialog::AboutDialog(QWidget *parent, Qt::WindowFlags flags) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8d0c59..238a47c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required (VERSION 2.8.6) # Version Number set (SIMPLE_HASHER_VERSION_MAJOR 1) set (SIMPLE_HASHER_VERSION_MINOR 0) -set (SIMPLE_HASHER_VERSION_PATCH 0) +set (SIMPLE_HASHER_VERSION_PATCH 1) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/SimpleHasher.cpp b/SimpleHasher.cpp index c74e580..10008f4 100644 --- a/SimpleHasher.cpp +++ b/SimpleHasher.cpp @@ -835,23 +835,26 @@ const QString SimpleHasher::guessHash(QFile &file) file.seek(0); auto data = file.read(150); // a bit more than the largest of the hashes (512 bits/4 char bits = 128). - QRegExp reg{"(([a-h]*)([A-H]*)([0-9]*))*"}; - - if(reg.indexIn(data) != -1) + if(data.length() > 32) { - auto hash = reg.cap(); + QRegExp reg{"(([a-h]*)([A-H]*)([0-9]*))*"}; - switch(hash.length()) + if(reg.indexIn(data) != -1) { - case 32 : return "MD5"; - case 40 : return "SHA-1"; - case 56 : return "SHA-224"; - case 64 : return "SHA-256"; - case 96 : return "SHA-384"; - case 128: return "SHA-512"; - case 48 : return "Tiger"; - default: - break; + auto hash = reg.cap(); + + switch(hash.length()) + { + case 32 : return "MD5"; + case 40 : return "SHA-1"; + case 56 : return "SHA-224"; + case 64 : return "SHA-256"; + case 96 : return "SHA-384"; + case 128: return "SHA-512"; + case 48 : return "Tiger"; + default: + break; + } } } @@ -964,17 +967,52 @@ void SimpleHasher::loadInformation() QStringList files; int begin = 0; auto data = file.readAll(); - while(data.indexOf('*', begin) != -1) + + if(data.indexOf('*', begin) != -1) + { + while(data.indexOf('*', begin) != -1) + { + begin = data.indexOf('*', begin) + 1; + auto end = data.indexOf('\n', begin); + if(end == -1) end = data.length(); + + auto fileName = data.mid(begin, end-begin); + + if(path.exists(fileName)) + { + files << path.absoluteFilePath(fileName); + } + + begin = end; + } + } + else { - begin = data.indexOf('*', begin) + 1; - auto end = data.indexOf('\n', begin); - if(end == -1) end = data.length(); + // files without '*' first. + file.seek(0); + auto line = file.readLine(); + while(!line.isEmpty()) + { + auto lineParts = QString(line).split(' '); + if(lineParts.size() == 2 && path.exists(lineParts[1])) + { + files << files << path.absoluteFilePath(lineParts[1]); + } - files << path.absoluteFilePath(data.mid(begin, end-begin)); - begin = end; + line = file.readLine(); + } } - addFilesToTable(files); + if(!files.empty()) + { + addFilesToTable(files); + } + else + { + fileErrors += tr("%1 error: %2\n").arg(filename).arg(tr("File doesn't contains hashes.")); + file.close(); + continue; + } QRegExp hashexp{"(([a-h]*)([A-H]*)([0-9]*))*"}; hashexp.setMinimal(false); diff --git a/SimpleHasher.h b/SimpleHasher.h index 7a616c8..c5a7f46 100644 --- a/SimpleHasher.h +++ b/SimpleHasher.h @@ -21,8 +21,8 @@ #define SIMPLEHASHER_H_ // Qt -#include #include "ui_SimpleHasher.h" +#include // C++ #include diff --git a/readme.md b/readme.md index 684f926..6cc74f6 100644 --- a/readme.md +++ b/readme.md @@ -48,7 +48,7 @@ Configuration dialog ![configuration](https://cloud.githubusercontent.com/assets/12167134/15993540/76f68e16-30e9-11e6-852f-328f1455117a.jpg) # Repository information -**Version**: 1.0.0 +**Version**: 1.0.1 **Status**: finished @@ -56,7 +56,7 @@ Configuration dialog | Language |files |blank |comment |code | |:-----------------------------|--------------:|------------:|-----------------:|-------:| -| C++ | 13 | 459 | 377 | 2006 | +| C++ | 13 | 462 | 378 | 2040 | | C/C++ Header | 12 | 199 | 493 | 383 | | CMake | 1 | 16 | 10 | 63 | -| **Total** | **26** | **674** | **880** |**2452**| +| **Total** | **26** | **677** | **881** |**2486**|