mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-10-12 21:40:54 -04:00
Using openDatabaseFile in List.
This commit is contained in:
parent
780e23301b
commit
cf23343911
1 changed files with 2 additions and 18 deletions
|
@ -22,14 +22,12 @@
|
||||||
|
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFile>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
#include "format/KeePass2Reader.h"
|
|
||||||
#include "keys/CompositeKey.h"
|
#include "keys/CompositeKey.h"
|
||||||
|
|
||||||
void printGroup(Group* group, QString baseName, int depth) {
|
void printGroup(Group* group, QString baseName, int depth) {
|
||||||
|
@ -81,22 +79,8 @@ int List::execute(int argc, char **argv)
|
||||||
QString line = inputTextStream.readLine();
|
QString line = inputTextStream.readLine();
|
||||||
CompositeKey key = CompositeKey::readFromLine(line);
|
CompositeKey key = CompositeKey::readFromLine(line);
|
||||||
|
|
||||||
QString databaseFilename = args.at(0);
|
Database* db = Database::openDatabaseFile(args.at(0), key);
|
||||||
QFile dbFile(databaseFilename);
|
if (db == nullptr) {
|
||||||
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()));
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue