summaryrefslogtreecommitdiffstats
path: root/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
diff options
context:
space:
mode:
authorhjk <qthjk@ovi.com>2011-11-19 12:41:47 +0100
committerTim Jenssen <tim.jenssen@nokia.com>2011-11-21 13:14:57 +0100
commit7a3e381ec098a5f011aeea69c5ec58dd66421545 (patch)
treee5081aa5037065fa4e429e2e82f61c471d41e49f /installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
parentec0f2ecb6f50805df4bb0f5f578531707d0eb575 (diff)
Whitespace style.
Change-Id: Ia850cf4766cf88054e9ff1a46371623835bf0137 Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp')
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp98
1 files changed, 42 insertions, 56 deletions
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
index 42d40cfbc..4ae146b97 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
@@ -39,10 +39,10 @@ public:
QString destination;
QString errorMessage;
- void setError(const QString& msg);
+ void setError(const QString &msg);
};
-void UFUncompressor::Private::setError(const QString& msg)
+void UFUncompressor::Private::setError(const QString &msg)
{
errorMessage = msg;
}
@@ -62,7 +62,7 @@ QString UFUncompressor::errorString() const
return d->errorMessage;
}
-void UFUncompressor::setFileName(const QString& fileName)
+void UFUncompressor::setFileName(const QString &fileName)
{
d->ufFileName = fileName;
}
@@ -72,7 +72,7 @@ QString UFUncompressor::fileName() const
return d->ufFileName;
}
-void UFUncompressor::setDestination(const QString& dest)
+void UFUncompressor::setDestination(const QString &dest)
{
d->destination = dest;
}
@@ -87,28 +87,27 @@ bool UFUncompressor::uncompress()
d->errorMessage.clear();
// First open the uf file for reading
- QFile ufFile( d->ufFileName );
- if( !ufFile.open(QFile::ReadOnly) ) {
- d->setError(tr("Couldn't open file for reading: %1").arg( ufFile.errorString() ));
+ QFile ufFile(d->ufFileName);
+ if (!ufFile.open(QFile::ReadOnly)) {
+ d->setError(tr("Couldn't open file for reading: %1").arg( ufFile.errorString()));
return false;
}
- QDataStream ufDS( &ufFile );
- ufDS.setVersion( QDataStream::Qt_4_2 );
- QCryptographicHash hash( QCryptographicHash::Md5 );
+ QDataStream ufDS(&ufFile);
+ ufDS.setVersion(QDataStream::Qt_4_2);
+ QCryptographicHash hash(QCryptographicHash::Md5);
// Now read the header.
UFHeader header;
ufDS >> header;
- if( ufDS.status() != QDataStream::Ok || !header.isValid() )
- {
- d->setError( tr( "Couldn't read the file header." ) );
+ if (ufDS.status() != QDataStream::Ok || !header.isValid()) {
+ d->setError(tr("Couldn't read the file header."));
return false;
}
header.addToHash(hash);
// Some basic checks.
- if( header.magic != QLatin1String( KD_UPDATER_UF_HEADER_MAGIC ) ) {
+ if (header.magic != QLatin1String( KD_UPDATER_UF_HEADER_MAGIC)) {
d->setError(tr("Wrong file format (magic number not found)"));
return false;
}
@@ -119,19 +118,16 @@ bool UFUncompressor::uncompress()
// Lets create the required directory structure
int numExpectedFiles = 0;
- for(int i=0; i<header.fileList.count(); i++)
- {
- const QString fileName = header.fileList[i];
+ for (int i = 0; i < header.fileList.count(); i++) {
+ const QString fileName = header.fileList.at(i);
// qDebug("ToUncompress %s", qPrintable(fileName));
- if( header.isDirList[i] )
- {
- if ( !dir.mkpath( fileName ) )
- {
- d->setError(tr("Could not create folder: %1/%2").arg( d->destination, fileName ));
+ if (header.isDirList.at(i)) {
+ if (!dir.mkpath(fileName)) {
+ d->setError(tr("Could not create folder: %1/%2").arg(d->destination, fileName));
return false;
}
- fileEngine.setFileName( QString(QLatin1String( "%1/%2" )).arg(d->destination, fileName) );
- fileEngine.setPermissions( header.permList[i] | QAbstractFileEngine::ExeOwnerPerm );
+ fileEngine.setFileName(QString(QLatin1String("%1/%2")).arg(d->destination, fileName));
+ fileEngine.setPermissions(header.permList[i] | QAbstractFileEngine::ExeOwnerPerm);
} else {
++numExpectedFiles;
}
@@ -139,51 +135,42 @@ bool UFUncompressor::uncompress()
// Lets now create files within these directories
int numActualFiles = 0;
- while( !ufDS.atEnd() && numActualFiles < numExpectedFiles )
- {
+ while (!ufDS.atEnd() && numActualFiles < numExpectedFiles) {
UFEntry ufEntry;
ufDS >> ufEntry;
- if( ufDS.status() != QDataStream::Ok || !ufEntry.isValid() )
- {
- d->setError( tr( "Could not read information for entry %1." ).arg( numActualFiles ) );
+ if (ufDS.status() != QDataStream::Ok || !ufEntry.isValid()) {
+ d->setError(tr("Could not read information for entry %1.").arg(numActualFiles));
return false;
}
ufEntry.addToHash(hash);
const QString completeFileName = QString(QLatin1String( "%1/%2" )).arg(d->destination, ufEntry.fileName);
- const QByteArray ba = qUncompress( ufEntry.fileData );
+ const QByteArray ba = qUncompress(ufEntry.fileData);
// check the size
- QDataStream stream( ufEntry.fileData );
- stream.setVersion( QDataStream::Qt_4_2 );
+ QDataStream stream(ufEntry.fileData);
+ stream.setVersion(QDataStream::Qt_4_2);
qint32 length = 0;
stream >> length;
- if( ba.length() != length ) // uncompress failed
- {
- d->setError(tr("Could not uncompress entry %1, corrupt data").arg( ufEntry.fileName ) );
+ if (ba.length() != length) { // uncompress failed
+ d->setError(tr("Could not uncompress entry %1, corrupt data").arg(ufEntry.fileName));
return false;
-
}
-
- QFile ufeFile( completeFileName );
- if ( !ufeFile.open( QFile::WriteOnly ) )
- {
- d->setError(tr("Could not open file %1 for writing: %2").arg( completeFileName, ufeFile.errorString() ));
+ QFile ufeFile(completeFileName);
+ if (!ufeFile.open(QFile::WriteOnly)) {
+ d->setError(tr("Could not open file %1 for writing: %2").arg(completeFileName, ufeFile.errorString()));
return false;
}
-
- const char* const data = ba.constData();
+ const char *const data = ba.constData();
const qint64 total = ba.size();
qint64 written = 0;
- while ( written < total )
- {
- const qint64 num = ufeFile.write( data+written, total-written );
- if ( num == -1 )
- {
- d->setError( tr("Failed writing uncompressed data to %1: %2").arg( completeFileName, ufeFile.errorString() ) );
+ while (written < total) {
+ const qint64 num = ufeFile.write(data + written, total - written);
+ if (num == -1) {
+ d->setError(tr("Failed writing uncompressed data to %1: %2").arg(completeFileName, ufeFile.errorString()));
return false;
}
written += num;
@@ -191,13 +178,12 @@ bool UFUncompressor::uncompress()
ufeFile.close();
- const QFile::Permissions perm = static_cast< QFile::Permissions >( ufEntry.permissions );
- ufeFile.setPermissions( perm );
+ const QFile::Permissions perm = static_cast<QFile::Permissions>(ufEntry.permissions);
+ ufeFile.setPermissions(perm);
- if ( ufeFile.error() != QFile::NoError )
- {
+ if (ufeFile.error() != QFile::NoError) {
ufeFile.remove();
- d->setError( tr("Failed writing uncompressed data to %1: %2").arg( completeFileName, ufeFile.errorString() ) );
+ d->setError(tr("Failed writing uncompressed data to %1: %2").arg(completeFileName, ufeFile.errorString()));
return false;
}
@@ -205,7 +191,7 @@ bool UFUncompressor::uncompress()
++numActualFiles;
}
- if( numExpectedFiles != numActualFiles ) {
+ if (numExpectedFiles != numActualFiles) {
d->errorMessage = tr("Corrupt file (wrong number of files)");
return false;
}
@@ -213,7 +199,7 @@ bool UFUncompressor::uncompress()
QByteArray hashdata;
ufDS >> hashdata;
- if( hashdata != hash.result() ) {
+ if (hashdata != hash.result()) {
d->errorMessage = tr("Corrupt file (wrong hash)");
return false;
}