qfiledevice.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qfiledevice.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
static const int QFILE_WRITEBUFFER_SIZE = 16384;QFileDevicePrivate::QFileDevicePrivate()
13 : fileEngine(0),-
writeBuffer(QFILE_WRITEBUFFER_SIZE),
14 cachedSize(0),-
15 error(QFile::NoError), lastWasWrite(false)-
16{-
17 writeBufferChunkSize = 16384;-
18}
executed 65126 times by 217 tests: end of block
Executed by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • ...
65126
19-
20QFileDevicePrivate::~QFileDevicePrivate()-
21{-
22 delete fileEngine;-
23 fileEngine = 0;-
24}-
25-
26QAbstractFileEngine * QFileDevicePrivate::engine() const-
27{-
28 if (!fileEngine)-
29 fileEngine = new QFSFileEngine;-
30 return fileEngine;-
31}-
32-
33void QFileDevicePrivate::setError(QFileDevice::FileError err)-
34{-
35 error = err;-
36 errorString.clear();-
37}-
38-
39void QFileDevicePrivate::setError(QFileDevice::FileError err, const QString &errStr)-
40{-
41 error = err;-
42 errorString = errStr;-
43}-
44-
45void QFileDevicePrivate::setError(QFileDevice::FileError err, int errNum)-
46{-
47 error = err;-
48 errorString = qt_error_string(errNum);-
49}-
50QFileDevice::QFileDevice()-
51 : QIODevice(*new QFileDevicePrivate, 0)-
52{-
53}-
54-
55-
56-
57QFileDevice::QFileDevice(QObject *parent)-
58 : QIODevice(*new QFileDevicePrivate, parent)-
59{-
60}-
61-
62-
63-
64QFileDevice::QFileDevice(QFileDevicePrivate &dd, QObject *parent)-
65 : QIODevice(dd, parent)-
66{-
67}-
68-
69-
70-
71-
72-
73QFileDevice::~QFileDevice()-
74{-
75 close();-
76}-
77bool QFileDevice::isSequential() const-
78{-
79 const QFileDevicePrivate * const d = d_func();-
80 return d->fileEngine && d->fileEngine->isSequential();-
81}-
82int QFileDevice::handle() const-
83{-
84 const QFileDevicePrivate * const d = d_func();-
85 if (!isOpen() || !d->fileEngine)-
86 return -1;-
87-
88 return d->fileEngine->handle();-
89}-
90-
91-
92-
93-
94-
95QString QFileDevice::fileName() const-
96{-
97 return QString();-
}
static inline qint64 _qfile_writeData(QAbstractFileEngine *engine, QRingBuffer *buffer)
{
qint64 ret = engine->write(buffer->readPointer(), buffer->nextDataBlockSize());
if (ret > 0)
buffer->free(ret);
return ret;}
99-
100-
101-
102-
103-
104bool QFileDevice::flush()-
105{-
106 QFileDevicePrivate * const d = d_func();-
107 if (!d->fileEngine
!d->fileEngineDescription
TRUEnever evaluated
FALSEevaluated 64296 times by 212 tests
Evaluated by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • ...
) {
0-64296
108 QMessageLogger(__FILE__, 287286, __PRETTY_FUNCTION__).warning("QFileDevice::flush: No file engine. Is IODevice open?");-
109 return
never executed: return false;
false;
never executed: return false;
0
110 }-
111-
112 if (!d->writeBuffer.isEmpty()
!d->writeBuffer.isEmpty()Description
TRUEevaluated 18450 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
FALSEevaluated 45846 times by 212 tests
Evaluated by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • ...
) {
18450-45846
113 qint64 size = d->writeBuffer.sizenextDataBlockSize();-
114 if (_qfile_writeData(qint64 written = d->fileEngine, &d->write(d->writeBuffer.readPointer(), size);-
115 if (written > 0
written > 0Description
TRUEevaluated 18444 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QFile
)
6-18444
116 d->writeBuffer.free(written);
executed 18444 times by 43 tests: d->writeBuffer.free(written);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
18444
117 if (written
written != sizeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QFile
FALSEevaluated 18444 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
written != sizeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QFile
FALSEevaluated 18444 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
!= size
written != sizeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QFile
FALSEevaluated 18444 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
) {
6-18444
118 QFileDevice::FileError err = d->fileEngine->error();-
119 if (err == QFileDevice::UnspecifiedError
err == QFileDe...specifiedErrorDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QFile
)
0-6
120 err = QFileDevice::WriteError;
never executed: err = QFileDevice::WriteError;
0
121 d->setError(err, d->fileEngine->errorString());-
122 return
executed 6 times by 1 test: return false;
Executed by:
  • tst_QFile
false;
executed 6 times by 1 test: return false;
Executed by:
  • tst_QFile
6
123 }-
124 }
executed 18444 times by 43 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
18444
125-
126 if (!d->fileEngine->flush()
!d->fileEngine->flush()Description
TRUEnever evaluated
FALSEevaluated 64290 times by 212 tests
Evaluated by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • ...
) {
0-64290
127 QFileDevice::FileError err = d->fileEngine->error();-
128 if (err == QFileDevice::UnspecifiedError
err == QFileDe...specifiedErrorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
129 err = QFileDevice::WriteError;
never executed: err = QFileDevice::WriteError;
0
130 d->setError(err, d->fileEngine->errorString());-
131 return
never executed: return false;
false;
never executed: return false;
0
132 }-
133 return
executed 64290 times by 212 tests: return true;
Executed by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • ...
true;
executed 64290 times by 212 tests: return true;
Executed by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTime
  • tst_QDateTimeEdit
  • tst_QDebug
  • ...
64290
134}-
135-
136-
137-
138-
139-
140-
141void QFileDevice::close()-
142{-
143 QFileDevicePrivate * const d = d_func();-
144 if (!isOpen())-
145 return;-
146 bool flushed = flush();-
147 QIODevice::close();-
148-
149-
150 d->lastWasWrite = false;-
151 d->writeBuffer.clear();-
152-
153-
154 if (d->fileEngine->close() && flushed)-
155 unsetError();-
156 else if (flushed)-
157 d->setError(d->fileEngine->error(), d->fileEngine->errorString());-
158}-
159-
160-
161-
162-
163qint64 QFileDevice::pos() const-
164{-
165 return QIODevice::pos();-
166}-
167bool QFileDevice::atEnd() const-
168{-
169 const QFileDevicePrivate * const d = d_func();-
170-
171-
172 if (!d->buffer.isEmptyisBufferEmpty()
!d->isBufferEmpty()Description
TRUEevaluated 121702 times by 36 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • ...
FALSEevaluated 4487 times by 45 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QLayout
  • ...
)
4487-121702
173 return
executed 121702 times by 36 tests: return false;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • ...
false;
executed 121702 times by 36 tests: return false;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • ...
121702
174-
175 if (!isOpen()
!isOpen()Description
TRUEnever evaluated
FALSEevaluated 4487 times by 45 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QLayout
  • ...
)
0-4487
176 return
never executed: return true;
true;
never executed: return true;
0
177-
178 if (!d->ensureFlushed()
!d->ensureFlushed()Description
TRUEnever evaluated
FALSEevaluated 4487 times by 45 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QLayout
  • ...
)
0-4487
179 return
never executed: return false;
false;
never executed: return false;
0
180-
181-
182 if (d->fileEngine->supportsExtension(QAbstractFileEngine::AtEndExtension)
d->fileEngine-...tEndExtension)Description
TRUEnever evaluated
FALSEevaluated 4487 times by 45 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QLayout
  • ...
) {
0-4487
183-
184-
185 return
never executed: return d->fileEngine->atEnd();
d->fileEngine->atEnd();
never executed: return d->fileEngine->atEnd();
0
186 }-
187-
188-
189-
190 if (pos() < d->cachedSize
pos() < d->cachedSizeDescription
TRUEevaluated 275 times by 5 tests
Evaluated by:
  • tst_QFile
  • tst_QFileInfo
  • tst_QImageReader
  • tst_QMimeDatabase
  • tst_QTextStream
FALSEevaluated 4212 times by 45 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QLayout
  • ...
)
275-4212
191 return
executed 275 times by 5 tests: return false;
Executed by:
  • tst_QFile
  • tst_QFileInfo
  • tst_QImageReader
  • tst_QMimeDatabase
  • tst_QTextStream
false;
executed 275 times by 5 tests: return false;
Executed by:
  • tst_QFile
  • tst_QFileInfo
  • tst_QImageReader
  • tst_QMimeDatabase
  • tst_QTextStream
275
192-
193-
194 return
executed 4212 times by 45 tests: return bytesAvailable() == 0;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QLayout
  • ...
bytesAvailable() == 0;
executed 4212 times by 45 tests: return bytesAvailable() == 0;
Executed by:
  • tst_QAccessibility
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QComboBox
  • tst_QCompleter
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QLayout
  • ...
4212
195}-
196bool QFileDevice::seek(qint64 off)-
197{-
198 QFileDevicePrivate * const d = d_func();-
199 if (!isOpen()) {-
200 QMessageLogger(__FILE__, 402404, __PRETTY_FUNCTION__).warning("QFileDevice::seek: IODevice is not open");-
201 return false;-
202 }-
203-
204 if (!d->ensureFlushed())-
205 return false;-
206-
207 if (!d->fileEngine->seek(off) || !QIODevice::seek(off)) {-
208 QFileDevice::FileError err = d->fileEngine->error();-
209 if (err == QFileDevice::UnspecifiedError)-
210 err = QFileDevice::PositionError;-
211 d->setError(err, d->fileEngine->errorString());-
212 return false;-
213 }-
214 unsetError();-
215 return true;-
216}-
217-
218-
219-
220-
221qint64 QFileDevice::readLineData(char *data, qint64 maxlen)-
222{-
223 QFileDevicePrivate * const d = d_func();-
224 if (!d->ensureFlushed())-
225 return -1;-
226-
227 qint64 read;-
228 if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) {-
229 read = d->fileEngine->readLine(data, maxlen);-
230 } else {-
231-
232-
233 read = QIODevice::readLineData(data, maxlen);-
234 }-
235-
236 if (read < maxlen) {-
237-
238 d->cachedSize = 0;-
239 }-
240-
241 return read;-
242}-
243-
244-
245-
246-
247qint64 QFileDevice::readData(char *data, qint64 len)-
248{-
249 QFileDevicePrivate * const d = d_func();-
250 if (!len)-
251 return 0;-
252 unsetError();-
253 if (!d->ensureFlushed())-
254 return -1;-
255-
256 const qint64 read = d->fileEngine->read(data, len);-
257 if (read < 0) {-
258 QFileDevice::FileError err = d->fileEngine->error();-
259 if (err == QFileDevice::UnspecifiedError)-
260 err = QFileDevice::ReadError;-
261 d->setError(err, d->fileEngine->errorString());-
262 }-
263-
264 if (read < len) {-
265-
266 d->cachedSize = 0;-
267 }-
268-
269 return read;-
270}-
271-
272-
273-
274-
275bool QFileDevicePrivate::putCharHelper(char c)-
276{-
277-
278-
279-
280-
281-
282 qint64 writeBufferSize = writeBuffer.size();-
283 if ((openMode & QIODevice::Unbuffered) || writeBufferSize + 1 >= QFILE_WRITEBUFFER_SIZEwriteBufferChunkSize
writeBufferSiz...ufferChunkSizeDescription
TRUEnever evaluated
FALSEevaluated 2144 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
0-2144
284-
285-
286-
287-
288 ) {-
289 return
never executed: return QIODevicePrivate::putCharHelper(c);
QIODevicePrivate::putCharHelper(c);
never executed: return QIODevicePrivate::putCharHelper(c);
0
290 }-
291-
292 if (!(openMode & QIODevice::WriteOnly)
!(openMode & Q...ce::WriteOnly)Description
TRUEnever evaluated
FALSEevaluated 2144 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
) {
0-2144
293 if (openMode == QIODevice::NotOpen
openMode == QIODevice::NotOpenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
294 QMessageLogger(__FILE__, 495498, __PRETTY_FUNCTION__).warning("QIODevice::putChar: Closed device");
never executed: QMessageLogger(__FILE__, 498, __PRETTY_FUNCTION__).warning("QIODevice::putChar: Closed device");
0
295 else-
296 QMessageLogger(__FILE__, 497500, __PRETTY_FUNCTION__).warning("QIODevice::putChar: ReadOnly device");
never executed: QMessageLogger(__FILE__, 500, __PRETTY_FUNCTION__).warning("QIODevice::putChar: ReadOnly device");
0
297 return
never executed: return false;
false;
never executed: return false;
0
298 }-
299-
300-
301 const bool sequential = isSequential();-
302 if (pos != devicePos
pos != devicePosDescription
TRUEnever evaluated
FALSEevaluated 2144 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
&& !sequential
!sequentialDescription
TRUEnever evaluated
FALSEnever evaluated
&& !q_func()->seek(pos)
!q_func()->seek(pos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0-2144
303 return
never executed: return false;
false;
never executed: return false;
0
304-
305 lastWasWrite = true;-
306-
307 int len = 1;-
308 *writeBuffer.reserve(1) = c;-
309-
310 if (!sequential
!sequentialDescription
TRUEevaluated 2144 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
FALSEnever evaluated
) {
0-2144
311 pos += len;-
312 devicePos += len;-
313 if (!buffer.isEmpty()
!buffer.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 2144 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
)
0-2144
314 buffer.skip(len);
never executed: buffer.skip(len);
0
315 }
executed 2144 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
2144
316-
317 return
executed 2144 times by 6 tests: return true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
true;
executed 2144 times by 6 tests: return true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QDataStream
  • tst_QFile
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QSettings
2144
318-
319}-
320-
321-
322-
323-
324qint64 QFileDevice::writeData(const char *data, qint64 len)-
325{-
326 QFileDevicePrivate * const d = d_func();-
327 unsetError();-
328 d->lastWasWrite = true;-
329 bool buffered = !(d->openMode & Unbuffered);-
330-
331-
332 if (buffered
bufferedDescription
TRUEevaluated 128830 times by 44 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
FALSEevaluated 651 times by 5 tests
Evaluated by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QNetworkReply
  • tst_qfileopenevent
&& (
(d->writeBuffe...ufferChunkSizeDescription
TRUEevaluated 542 times by 12 tests
Evaluated by:
  • tst_QFile
  • tst_QFileInfo
  • tst_QFtp
  • tst_QIODevice
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qnetworkreply - unknown status
FALSEevaluated 128288 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
d->writeBuffer.size() + len) > QFILE_WRITEBUFFER_SIZEd->writeBufferChunkSize
(d->writeBuffe...ufferChunkSizeDescription
TRUEevaluated 542 times by 12 tests
Evaluated by:
  • tst_QFile
  • tst_QFileInfo
  • tst_QFtp
  • tst_QIODevice
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qnetworkreply - unknown status
FALSEevaluated 128288 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
) {
542-128830
333 if (!flush()
!flush()Description
TRUEnever evaluated
FALSEevaluated 542 times by 12 tests
Evaluated by:
  • tst_QFile
  • tst_QFileInfo
  • tst_QFtp
  • tst_QIODevice
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qnetworkreply - unknown status
)
0-542
334 return
never executed: return -1;
-1;
never executed: return -1;
0
335 }
executed 542 times by 12 tests: end of block
Executed by:
  • tst_QFile
  • tst_QFileInfo
  • tst_QFtp
  • tst_QIODevice
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qnetworkreply - unknown status
542
336-
337-
338-
339 if (!buffered
!bufferedDescription
TRUEevaluated 651 times by 5 tests
Evaluated by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QNetworkReply
  • tst_qfileopenevent
FALSEevaluated 128830 times by 44 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
|| len > QFILE_WRITEBUFFER_SIZEd->writeBufferChunkSize
len > d->writeBufferChunkSizeDescription
TRUEevaluated 53 times by 8 tests
Evaluated by:
  • tst_QFile
  • tst_QIODevice
  • tst_QImageWriter
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qnetworkreply - unknown status
FALSEevaluated 128777 times by 43 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
) {
53-128830
340 const qint64 ret = d->fileEngine->write(data, len);-
341 if (ret < 0
ret < 0Description
TRUEnever evaluated
FALSEevaluated 704 times by 11 tests
Evaluated by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QIODevice
  • tst_QImageWriter
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qfileopenevent
  • tst_qnetworkreply - unknown status
) {
0-704
342 QFileDevice::FileError err = d->fileEngine->error();-
343 if (err == QFileDevice::UnspecifiedError
err == QFileDe...specifiedErrorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
344 err = QFileDevice::WriteError;
never executed: err = QFileDevice::WriteError;
0
345 d->setError(err, d->fileEngine->errorString());-
346 }
never executed: end of block
0
347 return
executed 704 times by 11 tests: return ret;
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QIODevice
  • tst_QImageWriter
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qfileopenevent
  • tst_qnetworkreply - unknown status
ret;
executed 704 times by 11 tests: return ret;
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QIODevice
  • tst_QImageWriter
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QStorageInfo
  • tst_QTextStream
  • tst_qfileopenevent
  • tst_qnetworkreply - unknown status
704
348 }-
349-
350-
351 char *writePointer =d->writeBuffer.reserve(len);-
if (len == 1)
*writePointer = *data;
else if (len)
::memcpyappend(writePointer,data, len);
352 return
executed 128777 times by 43 tests: return len;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
len;
executed 128777 times by 43 tests: return len;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QColorDialog
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFtp
  • tst_QGraphicsProxyWidget
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPainter
  • tst_QPainterPath
  • tst_QPixmap
  • tst_QPrinter
  • ...
128777
353}-
354QFileDevice::FileError QFileDevice::error() const-
355{-
356 const QFileDevicePrivate * const d = d_func();-
357 return d->error;-
358}-
359-
360-
361-
362-
363-
364-
365void QFileDevice::unsetError()-
366{-
367 QFileDevicePrivate * const d = d_func();-
368 d->setError(QFileDevice::NoError);-
369}-
370qint64 QFileDevice::size() const-
371{-
372 const QFileDevicePrivate * const d = d_func();-
373 if (!d->ensureFlushed())-
374 return 0;-
375 d->cachedSize = d->engine()->size();-
376 return d->cachedSize;-
377}-
378bool QFileDevice::resize(qint64 sz)-
379{-
380 QFileDevicePrivate * const d = d_func();-
381 if (!d->ensureFlushed())-
382 return false;-
383 d->engine();-
384 if (isOpen() && d->fileEngine->pos() > sz)-
385 seek(sz);-
386 if (d->fileEngine->setSize(sz)) {-
387 unsetError();-
388 d->cachedSize = sz;-
389 return true;-
390 }-
391 d->cachedSize = 0;-
392 d->setError(QFile::ResizeError, d->fileEngine->errorString());-
393 return false;-
394}-
395-
396-
397-
398-
399-
400-
401-
402QFile::Permissions QFileDevice::permissions() const-
403{-
404 const QFileDevicePrivate * const d = d_func();-
405 QAbstractFileEngine::FileFlags perms = d->engine()->fileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask;-
406 return QFile::Permissions((int)perms);-
407}-
408bool QFileDevice::setPermissions(Permissions permissions)-
409{-
410 QFileDevicePrivate * const d = d_func();-
411 if (d->engine()->setPermissions(permissions)) {-
412 unsetError();-
413 return true;-
414 }-
415 d->setError(QFile::PermissionsError, d->fileEngine->errorString());-
416 return false;-
417}-
418uchar *QFileDevice::map(qint64 offset, qint64 size, MemoryMapFlags flags)-
419{-
420 QFileDevicePrivate * const d = d_func();-
421 if (d->engine()-
422 && d->fileEngine->supportsExtension(QAbstractFileEngine::MapExtension)) {-
423 unsetError();-
424 uchar *address = d->fileEngine->map(offset, size, flags);-
425 if (address == 0)-
426 d->setError(d->fileEngine->error(), d->fileEngine->errorString());-
427 return address;-
428 }-
429 return 0;-
430}-
431bool QFileDevice::unmap(uchar *address)-
432{-
433 QFileDevicePrivate * const d = d_func();-
434 if (d->engine()-
435 && d->fileEngine->supportsExtension(QAbstractFileEngine::UnMapExtension)) {-
436 unsetError();-
437 bool success = d->fileEngine->unmap(address);-
438 if (!success)-
439 d->setError(d->fileEngine->error(), d->fileEngine->errorString());-
440 return success;-
441 }-
442 d->setError(PermissionsError, tr("No file engine available or engine does not support UnMapExtension"));-
443 return false;-
444}-
445-
446-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9