summaryrefslogtreecommitdiffstats
path: root/installerbuilder/common
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-05-31 12:23:12 +0200
committerkh1 <qt-info@nokia.com>2011-05-31 12:23:12 +0200
commitae0bf2171862e1d61365a034a0821d7441db92bd (patch)
tree17567e691ef89e2689acd837e2c7e10086dc70b2 /installerbuilder/common
parentc48df16782a745d616fffd9e9336a2a0542eb03c (diff)
Add convenient function.
Diffstat (limited to 'installerbuilder/common')
-rw-r--r--installerbuilder/common/fileutils.cpp12
-rw-r--r--installerbuilder/common/fileutils.h3
2 files changed, 11 insertions, 4 deletions
diff --git a/installerbuilder/common/fileutils.cpp b/installerbuilder/common/fileutils.cpp
index 60365abc6..0dd2f7772 100644
--- a/installerbuilder/common/fileutils.cpp
+++ b/installerbuilder/common/fileutils.cpp
@@ -129,6 +129,12 @@ QString QInstaller::pathFromUrl(const QUrl &url)
return str;
}
+void QInstaller::openForRead(QIODevice *dev, const QString &name)
+{
+ Q_ASSERT(dev);
+ if (!dev->open(QIODevice::ReadOnly))
+ throw Error(QObject::tr("Cannot open file %1 for reading: %2").arg(name, dev->errorString()));
+}
void QInstaller::openForWrite(QIODevice *dev, const QString &name)
{
@@ -137,11 +143,11 @@ void QInstaller::openForWrite(QIODevice *dev, const QString &name)
throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg(name, dev->errorString()));
}
-void QInstaller::openForRead(QIODevice *dev, const QString &name)
+void QInstaller::openForAppend(QIODevice *dev, const QString &name)
{
Q_ASSERT(dev);
- if (!dev->open(QIODevice::ReadOnly))
- throw Error(QObject::tr("Cannot open file %1 for reading: %2").arg(name, dev->errorString()));
+ if (!dev->open(QIODevice::ReadWrite | QIODevice::Append))
+ throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg(name, dev->errorString()));
}
qint64 QInstaller::blockingWrite(QIODevice *out, const char *buffer, qint64 size)
diff --git a/installerbuilder/common/fileutils.h b/installerbuilder/common/fileutils.h
index 8be14f08f..4c28d9d09 100644
--- a/installerbuilder/common/fileutils.h
+++ b/installerbuilder/common/fileutils.h
@@ -61,8 +61,9 @@ private:
QSet<QString> m_paths;
};
- void INSTALLER_EXPORT openForWrite(QIODevice *dev, const QString &name);
void INSTALLER_EXPORT openForRead(QIODevice *dev, const QString &name);
+ void INSTALLER_EXPORT openForWrite(QIODevice *dev, const QString &name);
+ void INSTALLER_EXPORT openForAppend(QIODevice *dev, const QString &name);
qint64 INSTALLER_EXPORT blockingRead(QIODevice *in, char *buffer, qint64 size);
void INSTALLER_EXPORT blockingCopy(QIODevice *in, QIODevice *out, qint64 size);