From 0b8309b6b7820c0036f1f8cd2253477e67a8b165 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 31 Mar 2009 18:25:28 +0200 Subject: use ftruncate() to resize a buffered file using truncate() on the file name was a bad idea, since the OS had to open it again - on some file systems, this would just error out, so QFile::resize() failed by default. Reviewed-by: Thiago --- src/corelib/io/qfsfileengine_unix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 0d88b06..8a0a3f5 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -935,6 +935,8 @@ bool QFSFileEngine::setSize(qint64 size) Q_D(QFSFileEngine); if (d->fd != -1) return !QT_FTRUNCATE(d->fd, size); + if (d->fh) + return !QT_FTRUNCATE(QT_FILENO(d->fh), size); return !QT_TRUNCATE(d->nativeFilePath.constData(), size); } -- cgit v0.12