summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer/utils.cpp')
-rw-r--r--src/libs/installer/utils.cpp56
1 files changed, 43 insertions, 13 deletions
diff --git a/src/libs/installer/utils.cpp b/src/libs/installer/utils.cpp
index d76eab696..a11ac774e 100644
--- a/src/libs/installer/utils.cpp
+++ b/src/libs/installer/utils.cpp
@@ -214,24 +214,40 @@ QInstaller::VerboseWriter::VerboseWriter()
QInstaller::VerboseWriter::~VerboseWriter()
{
+ if (preFileBuffer.isOpen()) {
+ PlainVerboseWriterOutput output;
+ (void)flush(&output);
+ }
+}
+
+bool QInstaller::VerboseWriter::flush(VerboseWriterOutput *output)
+{
stream.flush();
if (logFileName.isEmpty()) // binarycreator
- return;
+ return true;
+ if (!preFileBuffer.isOpen())
+ return true;
//if the installer installed nothing - there is no target directory - where the logfile can be saved
if (!QFileInfo(logFileName).absoluteDir().exists())
- return;
-
- QFile output(logFileName);
- if (output.open(QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text)) {
- QString logInfo;
- logInfo += QLatin1String("************************************* Invoked: ");
- logInfo += currentDateTimeAsString;
- logInfo += QLatin1String("\n");
- output.write(logInfo.toLocal8Bit());
- output.write(preFileBuffer.data());
- output.close();
+ return true;
+
+ QString logInfo;
+ logInfo += QLatin1String("************************************* Invoked: ");
+ logInfo += currentDateTimeAsString;
+ logInfo += QLatin1String("\n");
+
+ QBuffer buffer;
+ buffer.open(QIODevice::WriteOnly);
+ buffer.write(logInfo.toLocal8Bit());
+ buffer.write(preFileBuffer.data());
+ buffer.close();
+
+ if (output->write(logFileName, QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text, buffer.data())) {
+ preFileBuffer.close();
+ stream.setDevice(0);
+ return true;
}
- stream.setDevice(0);
+ return false;
}
void QInstaller::VerboseWriter::setFileName(const QString &fileName)
@@ -252,6 +268,20 @@ void QInstaller::VerboseWriter::appendLine(const QString &msg)
stream << msg << endl;
}
+QInstaller::VerboseWriterOutput::~VerboseWriterOutput()
+{
+}
+
+bool QInstaller::PlainVerboseWriterOutput::write(const QString &fileName, QIODevice::OpenMode openMode, const QByteArray &data)
+{
+ QFile output(fileName);
+ if (output.open(openMode)) {
+ output.write(data);
+ return true;
+ }
+ return false;
+}
+
#ifdef Q_OS_WIN
// taken from qcoreapplication_p.h
template<typename Char>