add/unify i/o error handling

lots of use of Utils::FileSaver and Utils::FileReader

Task-number: QTCREATORBUG-1619
This commit is contained in:
Oswald Buddenhagen
2011-03-30 15:15:15 +02:00
parent fae7dc9584
commit 45c9cf7a12
70 changed files with 632 additions and 710 deletions

View File

@@ -41,6 +41,7 @@
#include "sshkeyexchange_p.h"
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <botan/exceptn.h>
#include <botan/init.h>
@@ -410,18 +411,12 @@ void SshConnectionPrivate::handleServiceAcceptPacket()
m_sendFacility.sendUserAuthByPwdRequestPacket(m_connParams.userName.toUtf8(),
SshCapabilities::SshConnectionService, m_connParams.password.toUtf8());
} else {
QFile privKeyFile(m_connParams.privateKeyFile);
bool couldOpen = privKeyFile.open(QIODevice::ReadOnly);
QByteArray contents;
if (couldOpen)
contents = privKeyFile.readAll();
if (!couldOpen || privKeyFile.error() != QFile::NoError) {
Utils::FileReader reader;
if (!reader.fetch(m_connParams.privateKeyFile))
throw SshClientException(SshKeyFileError,
tr("Could not read private key file: %1")
.arg(privKeyFile.errorString()));
}
tr("Private key error: %1").arg(reader.errorString()));
m_sendFacility.createAuthenticationKey(contents);
m_sendFacility.createAuthenticationKey(reader.data());
m_sendFacility.sendUserAuthByKeyRequestPacket(m_connParams.userName.toUtf8(),
SshCapabilities::SshConnectionService);
}