Using openDatabaseFile in List.

This commit is contained in:
Louis-Bertrand Varin 2017-03-12 13:57:44 -04:00 committed by Louis-Bertrand Varin
parent 780e23301b
commit cf23343911

View File

@ -22,14 +22,12 @@
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QFile>
#include <QStringList>
#include <QTextStream>
#include "core/Database.h"
#include "core/Entry.h"
#include "core/Group.h"
#include "format/KeePass2Reader.h"
#include "keys/CompositeKey.h"
void printGroup(Group* group, QString baseName, int depth) {
@ -81,22 +79,8 @@ int List::execute(int argc, char **argv)
QString line = inputTextStream.readLine();
CompositeKey key = CompositeKey::readFromLine(line);
QString databaseFilename = args.at(0);
QFile dbFile(databaseFilename);
if (!dbFile.exists()) {
qCritical("File %s does not exist.", qPrintable(databaseFilename));
return EXIT_FAILURE;
}
if (!dbFile.open(QIODevice::ReadOnly)) {
qCritical("Unable to open file %s.", qPrintable(databaseFilename));
return EXIT_FAILURE;
}
KeePass2Reader reader;
Database* db = reader.readDatabase(&dbFile, key);
if (reader.hasError()) {
qCritical("Error while parsing the database:\n%s\n", qPrintable(reader.errorString()));
Database* db = Database::openDatabaseFile(args.at(0), key);
if (db == nullptr) {
return EXIT_FAILURE;
}