mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-06 08:35:37 -04:00
Improve Database and CLI tests
This commit is contained in:
parent
744b4abce8
commit
1e694271a3
9 changed files with 127 additions and 91 deletions
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "TemporaryFile.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QTextStream>
|
||||
|
||||
TemporaryFile::TemporaryFile()
|
||||
: TemporaryFile(nullptr)
|
||||
|
@ -47,9 +47,35 @@ TemporaryFile::TemporaryFile(const QString& templateName, QObject* parent)
|
|||
tmp.close();
|
||||
}
|
||||
|
||||
TemporaryFile::~TemporaryFile()
|
||||
{
|
||||
remove();
|
||||
}
|
||||
|
||||
bool TemporaryFile::open()
|
||||
{
|
||||
return QFile::open(QIODevice::ReadWrite);
|
||||
}
|
||||
|
||||
#endif
|
||||
bool TemporaryFile::copyFromFile(const QString& otherFileName)
|
||||
{
|
||||
close();
|
||||
if (!open(QFile::WriteOnly | QFile::Truncate)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile otherFile(otherFileName);
|
||||
if (!otherFile.open(QFile::ReadOnly)) {
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
while(!(data = otherFile.read(1024)).isEmpty()) {
|
||||
write(data);
|
||||
}
|
||||
|
||||
otherFile.close();
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue