OpenCoverage

qabstractfileengine.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qabstractfileengine.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "private/qabstractfileengine_p.h"-
41#include "private/qfsfileengine_p.h"-
42#ifdef QT_BUILD_CORE_LIB-
43#include "private/qresource_p.h"-
44#endif-
45#include "qdatetime.h"-
46#include "qreadwritelock.h"-
47#include "qvariant.h"-
48// built-in handlers-
49#include "qdiriterator.h"-
50#include "qstringbuilder.h"-
51-
52#include <QtCore/private/qfilesystementry_p.h>-
53#include <QtCore/private/qfilesystemmetadata_p.h>-
54#include <QtCore/private/qfilesystemengine_p.h>-
55-
56QT_BEGIN_NAMESPACE-
57-
58/*!-
59 \class QAbstractFileEngineHandler-
60 \inmodule QtCore-
61 \reentrant-
62 \internal-
63-
64 \brief The QAbstractFileEngineHandler class provides a way to register-
65 custom file engines with your application.-
66-
67 \ingroup io-
68 \since 4.1-
69-
70 QAbstractFileEngineHandler is a factory for creating QAbstractFileEngine-
71 objects (file engines), which are used internally by QFile, QFileInfo, and-
72 QDir when working with files and directories.-
73-
74 When you open a file, Qt chooses a suitable file engine by passing the-
75 file name from QFile or QDir through an internal list of registered file-
76 engine handlers. The first handler to recognize the file name is used to-
77 create the engine. Qt provides internal file engines for working with-
78 regular files and resources, but you can also register your own-
79 QAbstractFileEngine subclasses.-
80-
81 To install an application-specific file engine, you subclass-
82 QAbstractFileEngineHandler and reimplement create(). When you instantiate-
83 the handler (e.g. by creating an instance on the stack or on the heap), it-
84 will automatically register with Qt. (The latest registered handler takes-
85 precedence over existing handlers.)-
86-
87 For example:-
88-
89 \snippet code/src_corelib_io_qabstractfileengine.cpp 0-
90-
91 When the handler is destroyed, it is automatically removed from Qt.-
92-
93 The most common approach to registering a handler is to create an instance-
94 as part of the start-up phase of your application. It is also possible to-
95 limit the scope of the file engine handler to a particular area of-
96 interest (e.g. a special file dialog that needs a custom file engine). By-
97 creating the handler inside a local scope, you can precisely control the-
98 area in which your engine will be applied without disturbing file-
99 operations in other parts of your application.-
100-
101 \sa QAbstractFileEngine, QAbstractFileEngine::create()-
102*/-
103-
104static bool qt_file_engine_handlers_in_use = false;-
105-
106/*-
107 All application-wide handlers are stored in this list. The mutex must be-
108 acquired to ensure thread safety.-
109 */-
110Q_GLOBAL_STATIC_WITH_ARGS(QReadWriteLock, fileEngineHandlerMutex, (QReadWriteLock::Recursive))
executed 3 times by 3 tests: end of block
Executed by:
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
executed 3 times by 3 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
executed 120 times by 6 tests: return &holder.value;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
guard.load() =...c::InitializedDescription
TRUEevaluated 3 times by 3 tests
Evaluated by:
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
FALSEnever evaluated
0-120
111static bool qt_abstractfileenginehandlerlist_shutDown = false;-
112class QAbstractFileEngineHandlerList : public QList<QAbstractFileEngineHandler *>-
113{-
114public:-
115 ~QAbstractFileEngineHandlerList()-
116 {-
117 QWriteLocker locker(fileEngineHandlerMutex());-
118 qt_abstractfileenginehandlerlist_shutDown = true;-
119 }
executed 3 times by 3 tests: end of block
Executed by:
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
3
120};-
121Q_GLOBAL_STATIC(QAbstractFileEngineHandlerList, fileEngineHandlers)
executed 3 times by 3 tests: end of block
Executed by:
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
executed 3 times by 3 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
executed 117 times by 3 tests: return &holder.value;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
guard.load() =...c::InitializedDescription
TRUEevaluated 3 times by 3 tests
Evaluated by:
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
FALSEnever evaluated
0-117
122-
123/*!-
124 Constructs a file handler and registers it with Qt. Once created this-
125 handler's create() function will be called (along with all the other-
126 handlers) for any paths used. The most recently created handler that-
127 recognizes the given path (i.e. that returns a QAbstractFileEngine) is-
128 used for the new path.-
129-
130 \sa create()-
131 */-
132QAbstractFileEngineHandler::QAbstractFileEngineHandler()-
133{-
134 QWriteLocker locker(fileEngineHandlerMutex());-
135 qt_file_engine_handlers_in_use = true;-
136 fileEngineHandlers()->prepend(this);-
137}
executed 15 times by 3 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
15
138-
139/*!-
140 Destroys the file handler. This will automatically unregister the handler-
141 from Qt.-
142 */-
143QAbstractFileEngineHandler::~QAbstractFileEngineHandler()-
144{-
145 QWriteLocker locker(fileEngineHandlerMutex());-
146 // Remove this handler from the handler list only if the list is valid.-
147 if (!qt_abstractfileenginehandlerlist_shutDown) {
!qt_abstractfi...rlist_shutDownDescription
TRUEevaluated 15 times by 3 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
FALSEnever evaluated
0-15
148 QAbstractFileEngineHandlerList *handlers = fileEngineHandlers();-
149 handlers->removeOne(this);-
150 if (handlers->isEmpty())
handlers->isEmpty()Description
TRUEevaluated 14 times by 3 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFile
1-14
151 qt_file_engine_handlers_in_use = false;
executed 14 times by 3 tests: qt_file_engine_handlers_in_use = false;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
14
152 }
executed 15 times by 3 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
15
153}
executed 15 times by 3 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
15
154-
155/*-
156 \internal-
157-
158 Handles calls to custom file engine handlers.-
159*/-
160QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path)-
161{-
162 QAbstractFileEngine *engine = 0;-
163-
164 if (qt_file_engine_handlers_in_use) {
qt_file_engine_handlers_in_useDescription
TRUEevaluated 87 times by 3 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
FALSEevaluated 305828 times by 303 tests
Evaluated by:
  • tst_Gestures
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QCheckBox
  • tst_QClipboard
  • tst_QColorDialog
  • tst_QColumnView
  • ...
87-305828
165 QReadLocker locker(fileEngineHandlerMutex());-
166-
167 // check for registered handlers that can load the file-
168 QAbstractFileEngineHandlerList *handlers = fileEngineHandlers();-
169 for (int i = 0; i < handlers->size(); i++) {
i < handlers->size()Description
TRUEevaluated 87 times by 3 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QFile
34-87
170 if ((engine = handlers->at(i)->create(path)))
(engine = hand...>create(path))Description
TRUEevaluated 53 times by 3 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QFile
34-53
171 break;
executed 53 times by 3 tests: break;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
53
172 }
executed 34 times by 2 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QFile
34
173 }
executed 87 times by 3 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
87
174-
175 return engine;
executed 305915 times by 303 tests: return engine;
Executed by:
  • tst_Gestures
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • tst_QChar
  • tst_QCheckBox
  • tst_QClipboard
  • tst_QColorDialog
  • tst_QColumnView
  • ...
305915
176}-
177-
178/*!-
179 \fn QAbstractFileEngine *QAbstractFileEngineHandler::create(const QString &fileName) const-
180-
181 Creates a file engine for file \a fileName. Returns 0 if this-
182 file handler cannot handle \a fileName.-
183-
184 Example:-
185-
186 \snippet code/src_corelib_io_qabstractfileengine.cpp 1-
187-
188 \sa QAbstractFileEngine::create()-
189*/-
190-
191/*!-
192 Creates and returns a QAbstractFileEngine suitable for processing \a-
193 fileName.-
194-
195 You should not need to call this function; use QFile, QFileInfo or-
196 QDir directly instead.-
197-
198 If you reimplemnt this function, it should only return file-
199 engines that knows how to handle \a fileName; otherwise, it should-
200 return 0.-
201-
202 \sa QAbstractFileEngineHandler-
203*/-
204QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName)-
205{-
206 QFileSystemEntry entry(fileName);-
207 QFileSystemMetaData metaData;-
208 QAbstractFileEngine *engine = QFileSystemEngine::resolveEntryAndCreateLegacyEngine(entry, metaData);-
209-
210#ifndef QT_NO_FSFILEENGINE-
211 if (!engine)
!engineDescription
TRUEevaluated 47048 times by 207 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_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QCryptographicHash
  • tst_QCssParser
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • ...
FALSEevaluated 14942 times by 83 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • tst_QFontDialog
  • tst_QFontMetrics
  • tst_QGlyphRun
  • ...
14942-47048
212 // fall back to regular file engine-
213 return new QFSFileEngine(entry.filePath());
executed 47048 times by 207 tests: return new QFSFileEngine(entry.filePath());
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
  • ...
47048
214#endif-
215-
216 return engine;
executed 14942 times by 83 tests: return engine;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • tst_QFontDialog
  • tst_QFontMetrics
  • tst_QGlyphRun
  • ...
14942
217}-
218-
219/*!-
220 \class QAbstractFileEngine-
221 \inmodule QtCore-
222 \reentrant-
223 \internal-
224-
225 \brief The QAbstractFileEngine class provides an abstraction for accessing-
226 the filesystem.-
227-
228 \ingroup io-
229 \since 4.1-
230-
231 The QDir, QFile, and QFileInfo classes all make use of a-
232 QAbstractFileEngine internally. If you create your own QAbstractFileEngine-
233 subclass (and register it with Qt by creating a QAbstractFileEngineHandler-
234 subclass), your file engine will be used when the path is one that your-
235 file engine handles.-
236-
237 A QAbstractFileEngine refers to one file or one directory. If the referent-
238 is a file, the setFileName(), rename(), and remove() functions are-
239 applicable. If the referent is a directory the mkdir(), rmdir(), and-
240 entryList() functions are applicable. In all cases the caseSensitive(),-
241 isRelativePath(), fileFlags(), ownerId(), owner(), and fileTime()-
242 functions are applicable.-
243-
244 A QAbstractFileEngine subclass can be created to do synchronous network I/O-
245 based file system operations, local file system operations, or to operate-
246 as a resource system to access file based resources.-
247-
248 \sa QAbstractFileEngineHandler-
249*/-
250-
251/*!-
252 \enum QAbstractFileEngine::FileName-
253-
254 These values are used to request a file name in a particular-
255 format.-
256-
257 \value DefaultName The same filename that was passed to the-
258 QAbstractFileEngine.-
259 \value BaseName The name of the file excluding the path.-
260 \value PathName The path to the file excluding the base name.-
261 \value AbsoluteName The absolute path to the file (including-
262 the base name).-
263 \value AbsolutePathName The absolute path to the file (excluding-
264 the base name).-
265 \value LinkName The full file name of the file that this file is a-
266 link to. (This will be empty if this file is not a link.)-
267 \value CanonicalName Often very similar to LinkName. Will return the true path to the file.-
268 \value CanonicalPathName Same as CanonicalName, excluding the base name.-
269 \value BundleName Returns the name of the bundle implies BundleType is set.-
270-
271 \omitvalue NFileNames-
272-
273 \sa fileName(), setFileName()-
274*/-
275-
276/*!-
277 \enum QAbstractFileEngine::FileFlag-
278-
279 The permissions and types of a file, suitable for OR'ing together.-
280-
281 \value ReadOwnerPerm The owner of the file has permission to read-
282 it.-
283 \value WriteOwnerPerm The owner of the file has permission to-
284 write to it.-
285 \value ExeOwnerPerm The owner of the file has permission to-
286 execute it.-
287 \value ReadUserPerm The current user has permission to read the-
288 file.-
289 \value WriteUserPerm The current user has permission to write to-
290 the file.-
291 \value ExeUserPerm The current user has permission to execute the-
292 file.-
293 \value ReadGroupPerm Members of the current user's group have-
294 permission to read the file.-
295 \value WriteGroupPerm Members of the current user's group have-
296 permission to write to the file.-
297 \value ExeGroupPerm Members of the current user's group have-
298 permission to execute the file.-
299 \value ReadOtherPerm All users have permission to read the file.-
300 \value WriteOtherPerm All users have permission to write to the-
301 file.-
302 \value ExeOtherPerm All users have permission to execute the file.-
303-
304 \value LinkType The file is a link to another file (or link) in-
305 the file system (i.e. not a file or directory).-
306 \value FileType The file is a regular file to the file system-
307 (i.e. not a link or directory)-
308 \value BundleType \macos and iOS: the file is a bundle; implies DirectoryType-
309 \value DirectoryType The file is a directory in the file system-
310 (i.e. not a link or file).-
311-
312 \value HiddenFlag The file is hidden.-
313 \value ExistsFlag The file actually exists in the file system.-
314 \value RootFlag The file or the file pointed to is the root of the filesystem.-
315 \value LocalDiskFlag The file resides on the local disk and can be passed to standard file functions.-
316 \value Refresh Passing this flag will force the file engine to refresh all flags.-
317-
318 \omitvalue PermsMask-
319 \omitvalue TypesMask-
320 \omitvalue FlagsMask-
321 \omitvalue FileInfoAll-
322-
323 \sa fileFlags(), setFileName()-
324*/-
325-
326/*!-
327 \enum QAbstractFileEngine::FileTime-
328-
329 These are used by the fileTime() function.-
330-
331 \value CreationTime When the file was created.-
332 \value ModificationTime When the file was most recently modified.-
333 \value AccessTime When the file was most recently accessed (e.g.-
334 read or written to).-
335-
336 \sa setFileName()-
337*/-
338-
339/*!-
340 \enum QAbstractFileEngine::FileOwner-
341-
342 \value OwnerUser The user who owns the file.-
343 \value OwnerGroup The group who owns the file.-
344-
345 \sa owner(), ownerId(), setFileName()-
346*/-
347-
348/*!-
349 Constructs a new QAbstractFileEngine that does not refer to any file or directory.-
350-
351 \sa setFileName()-
352 */-
353QAbstractFileEngine::QAbstractFileEngine() : d_ptr(new QAbstractFileEnginePrivate)-
354{-
355 d_ptr->q_ptr = this;-
356}
executed 18 times by 2 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QFile
18
357-
358/*!-
359 \internal-
360-
361 Constructs a QAbstractFileEngine.-
362 */-
363QAbstractFileEngine::QAbstractFileEngine(QAbstractFileEnginePrivate &dd) : d_ptr(&dd)-
364{-
365 d_ptr->q_ptr = this;-
366}
executed 98631 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
  • ...
98631
367-
368/*!-
369 Destroys the QAbstractFileEngine.-
370 */-
371QAbstractFileEngine::~QAbstractFileEngine()-
372{-
373}-
374-
375/*!-
376 \fn bool QAbstractFileEngine::open(QIODevice::OpenMode mode)-
377-
378 Opens the file in the specified \a mode. Returns \c true if the file-
379 was successfully opened; otherwise returns \c false.-
380-
381 The \a mode is an OR combination of QIODevice::OpenMode and-
382 QIODevice::HandlingMode values.-
383*/-
384bool QAbstractFileEngine::open(QIODevice::OpenMode openMode)-
385{-
386 Q_UNUSED(openMode);-
387 return false;
never executed: return false;
0
388}-
389-
390/*!-
391 Closes the file, returning true if successful; otherwise returns \c false.-
392-
393 The default implementation always returns \c false.-
394*/-
395bool QAbstractFileEngine::close()-
396{-
397 return false;
never executed: return false;
0
398}-
399-
400/*!-
401 \since 5.1-
402-
403 Flushes and syncs the file to disk.-
404-
405 Returns \c true if successful; otherwise returns \c false.-
406 The default implementation always returns \c false.-
407*/-
408bool QAbstractFileEngine::syncToDisk()-
409{-
410 return false;
never executed: return false;
0
411}-
412-
413/*!-
414 Flushes the open file, returning true if successful; otherwise returns-
415 false.-
416-
417 The default implementation always returns \c false.-
418*/-
419bool QAbstractFileEngine::flush()-
420{-
421 return false;
never executed: return false;
0
422}-
423-
424/*!-
425 Returns the size of the file.-
426*/-
427qint64 QAbstractFileEngine::size() const-
428{-
429 return 0;
never executed: return 0;
0
430}-
431-
432/*!-
433 Returns the current file position.-
434-
435 This is the position of the data read/write head of the file.-
436*/-
437qint64 QAbstractFileEngine::pos() const-
438{-
439 return 0;
never executed: return 0;
0
440}-
441-
442/*!-
443 \fn bool QAbstractFileEngine::seek(qint64 offset)-
444-
445 Sets the file position to the given \a offset. Returns \c true if-
446 the position was successfully set; otherwise returns \c false.-
447-
448 The offset is from the beginning of the file, unless the-
449 file is sequential.-
450-
451 \sa isSequential()-
452*/-
453bool QAbstractFileEngine::seek(qint64 pos)-
454{-
455 Q_UNUSED(pos);-
456 return false;
never executed: return false;
0
457}-
458-
459/*!-
460 Returns \c true if the file is a sequential access device; returns-
461 false if the file is a direct access device.-
462-
463 Operations involving size() and seek(int) are not valid on-
464 sequential devices.-
465*/-
466bool QAbstractFileEngine::isSequential() const-
467{-
468 return false;
executed 13 times by 1 test: return false;
Executed by:
  • tst_QAbstractFileEngine
13
469}-
470-
471/*!-
472 Requests that the file is deleted from the file system. If the-
473 operation succeeds return true; otherwise return false.-
474-
475 This virtual function must be reimplemented by all subclasses.-
476-
477 \sa setFileName(), rmdir()-
478 */-
479bool QAbstractFileEngine::remove()-
480{-
481 return false;
never executed: return false;
0
482}-
483-
484/*!-
485 Copies the contents of this file to a file with the name \a newName.-
486 Returns \c true on success; otherwise, false is returned.-
487*/-
488bool QAbstractFileEngine::copy(const QString &newName)-
489{-
490 Q_UNUSED(newName);-
491 return false;
never executed: return false;
0
492}-
493-
494/*!-
495 Requests that the file be renamed to \a newName in the file-
496 system. If the operation succeeds return true; otherwise return-
497 false.-
498-
499 This virtual function must be reimplemented by all subclasses.-
500-
501 \sa setFileName()-
502 */-
503bool QAbstractFileEngine::rename(const QString &newName)-
504{-
505 Q_UNUSED(newName);-
506 return false;
never executed: return false;
0
507}-
508-
509/*!-
510 \since 5.1-
511-
512 Requests that the file be renamed to \a newName in the file-
513 system. If the new name already exists, it must be overwritten.-
514 If the operation succeeds, returns \c true; otherwise returns-
515 false.-
516-
517 This virtual function must be reimplemented by all subclasses.-
518-
519 \sa setFileName()-
520 */-
521bool QAbstractFileEngine::renameOverwrite(const QString &newName)-
522{-
523 Q_UNUSED(newName);-
524 return false;
never executed: return false;
0
525}-
526-
527/*!-
528 Creates a link from the file currently specified by fileName() to-
529 \a newName. What a link is depends on the underlying filesystem-
530 (be it a shortcut on Windows or a symbolic link on Unix). Returns-
531 true if successful; otherwise returns \c false.-
532*/-
533bool QAbstractFileEngine::link(const QString &newName)-
534{-
535 Q_UNUSED(newName);-
536 return false;
never executed: return false;
0
537}-
538-
539/*!-
540 Requests that the directory \a dirName be created. If-
541 \a createParentDirectories is true, then any sub-directories in \a dirName-
542 that don't exist must be created. If \a createParentDirectories is false then-
543 any sub-directories in \a dirName must already exist for the function to-
544 succeed. If the operation succeeds return true; otherwise return-
545 false.-
546-
547 This virtual function must be reimplemented by all subclasses.-
548-
549 \sa setFileName(), rmdir(), isRelativePath()-
550 */-
551bool QAbstractFileEngine::mkdir(const QString &dirName, bool createParentDirectories) const-
552{-
553 Q_UNUSED(dirName);-
554 Q_UNUSED(createParentDirectories);-
555 return false;
never executed: return false;
0
556}-
557-
558/*!-
559 Requests that the directory \a dirName is deleted from the file-
560 system. When \a recurseParentDirectories is true, then any empty-
561 parent-directories in \a dirName must also be deleted. If-
562 \a recurseParentDirectories is false, only the \a dirName leaf-node-
563 should be deleted. In most file systems a directory cannot be deleted-
564 using this function if it is non-empty. If the operation succeeds-
565 return true; otherwise return false.-
566-
567 This virtual function must be reimplemented by all subclasses.-
568-
569 \sa setFileName(), remove(), mkdir(), isRelativePath()-
570 */-
571bool QAbstractFileEngine::rmdir(const QString &dirName, bool recurseParentDirectories) const-
572{-
573 Q_UNUSED(dirName);-
574 Q_UNUSED(recurseParentDirectories);-
575 return false;
never executed: return false;
0
576}-
577-
578/*!-
579 Requests that the file be set to size \a size. If \a size is larger-
580 than the current file then it is filled with 0's, if smaller it is-
581 simply truncated. If the operations succceeds return true; otherwise-
582 return false;-
583-
584 This virtual function must be reimplemented by all subclasses.-
585-
586 \sa size()-
587*/-
588bool QAbstractFileEngine::setSize(qint64 size)-
589{-
590 Q_UNUSED(size);-
591 return false;
never executed: return false;
0
592}-
593-
594/*!-
595 Should return true if the underlying file system is case-sensitive;-
596 otherwise return false.-
597-
598 This virtual function must be reimplemented by all subclasses.-
599 */-
600bool QAbstractFileEngine::caseSensitive() const-
601{-
602 return false;
never executed: return false;
0
603}-
604-
605/*!-
606 Return true if the file referred to by this file engine has a-
607 relative path; otherwise return false.-
608-
609 This virtual function must be reimplemented by all subclasses.-
610-
611 \sa setFileName()-
612 */-
613bool QAbstractFileEngine::isRelativePath() const-
614{-
615 return false;
never executed: return false;
0
616}-
617-
618/*!-
619 Requests that a list of all the files matching the \a filters-
620 list based on the \a filterNames in the file engine's directory-
621 are returned.-
622-
623 Should return an empty list if the file engine refers to a file-
624 rather than a directory, or if the directory is unreadable or does-
625 not exist or if nothing matches the specifications.-
626-
627 This virtual function must be reimplemented by all subclasses.-
628-
629 \sa setFileName()-
630 */-
631QStringList QAbstractFileEngine::entryList(QDir::Filters filters, const QStringList &filterNames) const-
632{-
633 QStringList ret;-
634 QDirIterator it(fileName(), filterNames, filters);-
635 while (it.hasNext()) {
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
0
636 it.next();-
637 ret << it.fileName();-
638 }
never executed: end of block
0
639 return ret;
never executed: return ret;
0
640}-
641-
642/*!-
643 This function should return the set of OR'd flags that are true-
644 for the file engine's file, and that are in the \a type's OR'd-
645 members.-
646-
647 In your reimplementation you can use the \a type argument as an-
648 optimization hint and only return the OR'd set of members that are-
649 true and that match those in \a type; in other words you can-
650 ignore any members not mentioned in \a type, thus avoiding some-
651 potentially expensive lookups or system calls.-
652-
653 This virtual function must be reimplemented by all subclasses.-
654-
655 \sa setFileName()-
656*/-
657QAbstractFileEngine::FileFlags QAbstractFileEngine::fileFlags(FileFlags type) const-
658{-
659 Q_UNUSED(type);-
660 return 0;
never executed: return 0;
0
661}-
662-
663/*!-
664 Requests that the file's permissions be set to \a perms. The argument-
665 perms will be set to the OR-ed together combination of-
666 QAbstractFileEngine::FileInfo, with only the QAbstractFileEngine::PermsMask being-
667 honored. If the operations succceeds return true; otherwise return-
668 false;-
669-
670 This virtual function must be reimplemented by all subclasses.-
671-
672 \sa size()-
673*/-
674bool QAbstractFileEngine::setPermissions(uint perms)-
675{-
676 Q_UNUSED(perms);-
677 return false;
never executed: return false;
0
678}-
679-
680/*!-
681 Return the file engine's current file name in the format-
682 specified by \a file.-
683-
684 If you don't handle some \c FileName possibilities, return the-
685 file name set in setFileName() when an unhandled format is-
686 requested.-
687-
688 This virtual function must be reimplemented by all subclasses.-
689-
690 \sa setFileName(), FileName-
691 */-
692QString QAbstractFileEngine::fileName(FileName file) const-
693{-
694 Q_UNUSED(file);-
695 return QString();
never executed: return QString();
0
696}-
697-
698/*!-
699 If \a owner is \c OwnerUser return the ID of the user who owns-
700 the file. If \a owner is \c OwnerGroup return the ID of the group-
701 that own the file. If you can't determine the owner return -2.-
702-
703 This virtual function must be reimplemented by all subclasses.-
704-
705 \sa owner(), setFileName(), FileOwner-
706 */-
707uint QAbstractFileEngine::ownerId(FileOwner owner) const-
708{-
709 Q_UNUSED(owner);-
710 return 0;
never executed: return 0;
0
711}-
712-
713/*!-
714 If \a owner is \c OwnerUser return the name of the user who owns-
715 the file. If \a owner is \c OwnerGroup return the name of the group-
716 that own the file. If you can't determine the owner return-
717 QString().-
718-
719 This virtual function must be reimplemented by all subclasses.-
720-
721 \sa ownerId(), setFileName(), FileOwner-
722 */-
723QString QAbstractFileEngine::owner(FileOwner owner) const-
724{-
725 Q_UNUSED(owner);-
726 return QString();
never executed: return QString();
0
727}-
728-
729/*!-
730 If \a time is \c CreationTime, return when the file was created.-
731 If \a time is \c ModificationTime, return when the file was most-
732 recently modified. If \a time is \c AccessTime, return when the-
733 file was most recently accessed (e.g. read or written).-
734 If the time cannot be determined return QDateTime() (an invalid-
735 date time).-
736-
737 This virtual function must be reimplemented by all subclasses.-
738-
739 \sa setFileName(), QDateTime, QDateTime::isValid(), FileTime-
740 */-
741QDateTime QAbstractFileEngine::fileTime(FileTime time) const-
742{-
743 Q_UNUSED(time);-
744 return QDateTime();
never executed: return QDateTime();
0
745}-
746-
747/*!-
748 Sets the file engine's file name to \a file. This file name is the-
749 file that the rest of the virtual functions will operate on.-
750-
751 This virtual function must be reimplemented by all subclasses.-
752-
753 \sa rename()-
754 */-
755void QAbstractFileEngine::setFileName(const QString &file)-
756{-
757 Q_UNUSED(file);-
758}
never executed: end of block
0
759-
760/*!-
761 Returns the native file handle for this file engine. This handle must be-
762 used with care; its value and type are platform specific, and using it-
763 will most likely lead to non-portable code.-
764*/-
765int QAbstractFileEngine::handle() const-
766{-
767 return -1;
executed 1 time by 1 test: return -1;
Executed by:
  • tst_QKeySequence
1
768}-
769-
770/*!-
771 \since 4.3-
772-
773 Returns \c true if the current position is at the end of the file; otherwise,-
774 returns \c false.-
775-
776 This function bases its behavior on calling extension() with-
777 AtEndExtension. If the engine does not support this extension, false is-
778 returned.-
779-
780 \sa extension(), supportsExtension(), QFile::atEnd()-
781*/-
782bool QAbstractFileEngine::atEnd() const-
783{-
784 return const_cast<QAbstractFileEngine *>(this)->extension(AtEndExtension);
never executed: return const_cast<QAbstractFileEngine *>(this)->extension(AtEndExtension);
0
785}-
786-
787/*!-
788 \since 4.4-
789-
790 Maps \a size bytes of the file into memory starting at \a offset.-
791 Returns a pointer to the memory if successful; otherwise returns \c false-
792 if, for example, an error occurs.-
793-
794 This function bases its behavior on calling extension() with-
795 MapExtensionOption. If the engine does not support this extension, 0 is-
796 returned.-
797-
798 \a flags is currently not used, but could be used in the future.-
799-
800 \sa unmap(), supportsExtension()-
801 */-
802-
803uchar *QAbstractFileEngine::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags)-
804{-
805 MapExtensionOption option;-
806 option.offset = offset;-
807 option.size = size;-
808 option.flags = flags;-
809 MapExtensionReturn r;-
810 if (!extension(MapExtension, &option, &r))
!extension(Map..., &option, &r)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QFile
FALSEevaluated 34366 times by 121 tests
Evaluated by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFactoryLoader
  • tst_QFile
  • tst_QFileDialog2
  • ...
24-34366
811 return 0;
executed 24 times by 1 test: return 0;
Executed by:
  • tst_QFile
24
812 return r.address;
executed 34366 times by 121 tests: return r.address;
Executed by:
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFactoryLoader
  • tst_QFile
  • tst_QFileDialog2
  • ...
34366
813}-
814-
815/*!-
816 \since 4.4-
817-
818 Unmaps the memory \a address. Returns \c true if the unmap succeeds; otherwise-
819 returns \c false.-
820-
821 This function bases its behavior on calling extension() with-
822 UnMapExtensionOption. If the engine does not support this extension, false is-
823 returned.-
824-
825 \sa map(), supportsExtension()-
826 */-
827bool QAbstractFileEngine::unmap(uchar *address)-
828{-
829 UnMapExtensionOption options;-
830 options.address = address;-
831 return extension(UnMapExtension, &options);
executed 32814 times by 2 tests: return extension(UnMapExtension, &options);
Executed by:
  • tst_LargeFile
  • tst_QFile
32814
832}-
833-
834/*!-
835 \since 4.3-
836 \class QAbstractFileEngineIterator-
837 \inmodule QtCore-
838 \brief The QAbstractFileEngineIterator class provides an iterator-
839 interface for custom file engines.-
840 \internal-
841-
842 If all you want is to iterate over entries in a directory, see-
843 QDirIterator instead. This class is only for custom file engine authors.-
844-
845 QAbstractFileEngineIterator is a unidirectional single-use virtual-
846 iterator that plugs into QDirIterator, providing transparent proxy-
847 iteration for custom file engines.-
848-
849 You can subclass QAbstractFileEngineIterator to provide an iterator when-
850 writing your own file engine. To plug the iterator into your file system,-
851 you simply return an instance of this subclass from a reimplementation of-
852 QAbstractFileEngine::beginEntryList().-
853-
854 Example:-
855-
856 \snippet code/src_corelib_io_qabstractfileengine.cpp 2-
857-
858 QAbstractFileEngineIterator is associated with a path, name filters, and-
859 entry filters. The path is the directory that the iterator lists entries-
860 in. The name filters and entry filters are provided for file engines that-
861 can optimize directory listing at the iterator level (e.g., network file-
862 systems that need to minimize network traffic), but they can also be-
863 ignored by the iterator subclass; QAbstractFileEngineIterator already-
864 provides the required filtering logics in the matchesFilters() function.-
865 You can call dirName() to get the directory name, nameFilters() to get a-
866 stringlist of name filters, and filters() to get the entry filters.-
867-
868 The pure virtual function hasNext() returns \c true if the current directory-
869 has at least one more entry (i.e., the directory name is valid and-
870 accessible, and we have not reached the end of the entry list), and false-
871 otherwise. Reimplement next() to seek to the next entry.-
872-
873 The pure virtual function currentFileName() returns the name of the-
874 current entry without advancing the iterator. The currentFilePath()-
875 function is provided for convenience; it returns the full path of the-
876 current entry.-
877-
878 Here is an example of how to implement an iterator that returns each of-
879 three fixed entries in sequence.-
880-
881 \snippet code/src_corelib_io_qabstractfileengine.cpp 3-
882-
883 Note: QAbstractFileEngineIterator does not deal with QDir::IteratorFlags;-
884 it simply returns entries for a single directory.-
885-
886 \sa QDirIterator-
887*/-
888-
889/*!-
890 \enum QAbstractFileEngineIterator::EntryInfoType-
891 \internal-
892-
893 This enum describes the different types of information that can be-
894 requested through the QAbstractFileEngineIterator::entryInfo() function.-
895*/-
896-
897/*!-
898 \typedef QAbstractFileEngine::Iterator-
899 \since 4.3-
900-
901 Synonym for QAbstractFileEngineIterator.-
902*/-
903-
904class QAbstractFileEngineIteratorPrivate-
905{-
906public:-
907 QString path;-
908 QDir::Filters filters;-
909 QStringList nameFilters;-
910 QFileInfo fileInfo;-
911};-
912-
913/*!-
914 Constructs a QAbstractFileEngineIterator, using the entry filters \a-
915 filters, and wildcard name filters \a nameFilters.-
916*/-
917QAbstractFileEngineIterator::QAbstractFileEngineIterator(QDir::Filters filters,-
918 const QStringList &nameFilters)-
919 : d(new QAbstractFileEngineIteratorPrivate)-
920{-
921 d->nameFilters = nameFilters;-
922 d->filters = filters;-
923}
executed 176 times by 7 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
176
924-
925/*!-
926 Destroys the QAbstractFileEngineIterator.-
927-
928 \sa QDirIterator-
929*/-
930QAbstractFileEngineIterator::~QAbstractFileEngineIterator()-
931{-
932}-
933-
934/*!-
935 Returns the path for this iterator. QDirIterator is responsible for-
936 assigning this path; it cannot change during the iterator's lifetime.-
937-
938 \sa nameFilters(), filters()-
939*/-
940QString QAbstractFileEngineIterator::path() const-
941{-
942 return d->path;
executed 1210 times by 7 tests: return d->path;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
1210
943}-
944-
945/*!-
946 \internal-
947-
948 Sets the iterator path to \a path. This function is called from within-
949 QDirIterator.-
950*/-
951void QAbstractFileEngineIterator::setPath(const QString &path)-
952{-
953 d->path = path;-
954}
executed 176 times by 7 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
176
955-
956/*!-
957 Returns the name filters for this iterator.-
958-
959 \sa QDir::nameFilters(), filters(), path()-
960*/-
961QStringList QAbstractFileEngineIterator::nameFilters() const-
962{-
963 return d->nameFilters;
never executed: return d->nameFilters;
0
964}-
965-
966/*!-
967 Returns the entry filters for this iterator.-
968-
969 \sa QDir::filter(), nameFilters(), path()-
970*/-
971QDir::Filters QAbstractFileEngineIterator::filters() const-
972{-
973 return d->filters;
never executed: return d->filters;
0
974}-
975-
976/*!-
977 \fn QString QAbstractFileEngineIterator::currentFileName() const = 0-
978-
979 This pure virtual function returns the name of the current directory-
980 entry, excluding the path.-
981-
982 \sa currentFilePath()-
983*/-
984-
985/*!-
986 Returns the path to the current directory entry. It's the same as-
987 prepending path() to the return value of currentFileName().-
988-
989 \sa currentFileName()-
990*/-
991QString QAbstractFileEngineIterator::currentFilePath() const-
992{-
993 QString name = currentFileName();-
994 if (!name.isNull()) {
!name.isNull()Description
TRUEevaluated 1036 times by 7 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
FALSEnever evaluated
0-1036
995 QString tmp = path();-
996 if (!tmp.isEmpty()) {
!tmp.isEmpty()Description
TRUEevaluated 1036 times by 7 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
FALSEnever evaluated
0-1036
997 if (!tmp.endsWith(QLatin1Char('/')))
!tmp.endsWith(...tin1Char('/'))Description
TRUEevaluated 894 times by 7 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
FALSEevaluated 142 times by 2 tests
Evaluated by:
  • tst_QDirIterator
  • tst_rcc
142-894
998 tmp.append(QLatin1Char('/'));
executed 894 times by 7 tests: tmp.append(QLatin1Char('/'));
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
894
999 name.prepend(tmp);-
1000 }
executed 1036 times by 7 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
1036
1001 }
executed 1036 times by 7 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
1036
1002 return name;
executed 1036 times by 7 tests: return name;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
1036
1003}-
1004-
1005/*!-
1006 The virtual function returns a QFileInfo for the current directory-
1007 entry. This function is provided for convenience. It can also be slightly-
1008 faster than creating a QFileInfo object yourself, as the object returned-
1009 by this function might contain cached information that QFileInfo otherwise-
1010 would have to access through the file engine.-
1011-
1012 \sa currentFileName()-
1013*/-
1014QFileInfo QAbstractFileEngineIterator::currentFileInfo() const-
1015{-
1016 QString path = currentFilePath();-
1017 if (d->fileInfo.filePath() != path)
d->fileInfo.filePath() != pathDescription
TRUEevaluated 518 times by 7 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
FALSEnever evaluated
0-518
1018 d->fileInfo.setFile(path);
executed 518 times by 7 tests: d->fileInfo.setFile(path);
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
518
1019-
1020 // return a shallow copy-
1021 return d->fileInfo;
executed 518 times by 7 tests: return d->fileInfo;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDir
  • tst_QDirIterator
  • tst_QFileInfo
  • tst_QResourceEngine
  • tst_QVariant
  • tst_rcc
518
1022}-
1023-
1024/*!-
1025 \internal-
1026-
1027 Returns the entry info \a type for this iterator's current directory entry-
1028 as a QVariant. If \a type is undefined for this entry, a null QVariant is-
1029 returned.-
1030-
1031 \sa QAbstractFileEngine::beginEntryList(), QDir::beginEntryList()-
1032*/-
1033QVariant QAbstractFileEngineIterator::entryInfo(EntryInfoType type) const-
1034{-
1035 Q_UNUSED(type)-
1036 return QVariant();
never executed: return QVariant();
0
1037}-
1038-
1039/*!-
1040 \fn virtual QString QAbstractFileEngineIterator::next() = 0-
1041-
1042 This pure virtual function advances the iterator to the next directory-
1043 entry, and returns the file path to the current entry.-
1044-
1045 This function can optionally make use of nameFilters() and filters() to-
1046 optimize its performance.-
1047-
1048 Reimplement this function in a subclass to advance the iterator.-
1049-
1050 \sa QDirIterator::next()-
1051*/-
1052-
1053/*!-
1054 \fn virtual bool QAbstractFileEngineIterator::hasNext() const = 0-
1055-
1056 This pure virtual function returns \c true if there is at least one more-
1057 entry in the current directory (i.e., the iterator path is valid and-
1058 accessible, and the iterator has not reached the end of the entry list).-
1059-
1060 \sa QDirIterator::hasNext()-
1061*/-
1062-
1063/*!-
1064 Returns an instance of a QAbstractFileEngineIterator using \a filters for-
1065 entry filtering and \a filterNames for name filtering. This function is-
1066 called by QDirIterator to initiate directory iteration.-
1067-
1068 QDirIterator takes ownership of the returned instance, and deletes it when-
1069 it's done.-
1070-
1071 \sa QDirIterator-
1072*/-
1073QAbstractFileEngine::Iterator *QAbstractFileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames)-
1074{-
1075 Q_UNUSED(filters);-
1076 Q_UNUSED(filterNames);-
1077 return 0;
never executed: return 0;
0
1078}-
1079-
1080/*!-
1081 \internal-
1082*/-
1083QAbstractFileEngine::Iterator *QAbstractFileEngine::endEntryList()-
1084{-
1085 return 0;
never executed: return 0;
0
1086}-
1087-
1088/*!-
1089 Reads a number of characters from the file into \a data. At most-
1090 \a maxlen characters will be read.-
1091-
1092 Returns -1 if a fatal error occurs, or 0 if there are no bytes to-
1093 read.-
1094*/-
1095qint64 QAbstractFileEngine::read(char *data, qint64 maxlen)-
1096{-
1097 Q_UNUSED(data);-
1098 Q_UNUSED(maxlen);-
1099 return -1;
never executed: return -1;
0
1100}-
1101-
1102/*!-
1103 Writes \a len bytes from \a data to the file. Returns the number-
1104 of characters written on success; otherwise returns -1.-
1105*/-
1106qint64 QAbstractFileEngine::write(const char *data, qint64 len)-
1107{-
1108 Q_UNUSED(data);-
1109 Q_UNUSED(len);-
1110 return -1;
never executed: return -1;
0
1111}-
1112-
1113/*!-
1114 This function reads one line, terminated by a '\\n' character, from the-
1115 file info \a data. At most \a maxlen characters will be read. The-
1116 end-of-line character is included.-
1117*/-
1118qint64 QAbstractFileEngine::readLine(char *data, qint64 maxlen)-
1119{-
1120 qint64 readSoFar = 0;-
1121 while (readSoFar < maxlen) {
readSoFar < maxlenDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFile
FALSEnever evaluated
0-8
1122 char c;-
1123 qint64 readResult = read(&c, 1);-
1124 if (readResult <= 0)
readResult <= 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFile
FALSEnever evaluated
0-8
1125 return (readSoFar > 0) ? readSoFar : -1;
executed 8 times by 1 test: return (readSoFar > 0) ? readSoFar : -1;
Executed by:
  • tst_QFile
8
1126 ++readSoFar;-
1127 *data++ = c;-
1128 if (c == '\n')
c == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
1129 return readSoFar;
never executed: return readSoFar;
0
1130 }
never executed: end of block
0
1131 return readSoFar;
never executed: return readSoFar;
0
1132}-
1133-
1134/*!-
1135 \enum QAbstractFileEngine::Extension-
1136 \since 4.3-
1137-
1138 This enum describes the types of extensions that the file engine can-
1139 support. Before using these extensions, you must verify that the extension-
1140 is supported (i.e., call supportsExtension()).-
1141-
1142 \value AtEndExtension Whether the current file position is at the end of-
1143 the file or not. This extension allows file engines that implement local-
1144 buffering to report end-of-file status without having to check the size of-
1145 the file. It is also useful for sequential files, where the size of the-
1146 file cannot be used to determine whether or not you have reached the end.-
1147 This extension returns \c true if the file is at the end; otherwise it returns-
1148 false. The input and output arguments to extension() are ignored.-
1149-
1150 \value FastReadLineExtension Whether the file engine provides a-
1151 fast implementation for readLine() or not. If readLine() remains-
1152 unimplemented in the file engine, QAbstractFileEngine will provide-
1153 an implementation based on calling read() repeatedly. If-
1154 supportsExtension() returns \c false for this extension, however,-
1155 QIODevice can provide a faster implementation by making use of its-
1156 internal buffer. For engines that already provide a fast readLine()-
1157 implementation, returning false for this extension can avoid-
1158 unnnecessary double-buffering in QIODevice.-
1159-
1160 \value MapExtension Whether the file engine provides the ability to map-
1161 a file to memory.-
1162-
1163 \value UnMapExtension Whether the file engine provides the ability to-
1164 unmap memory that was previously mapped.-
1165*/-
1166-
1167/*!-
1168 \class QAbstractFileEngine::ExtensionOption-
1169 \inmodule QtCore-
1170 \since 4.3-
1171 \brief provides an extended input argument to QAbstractFileEngine's-
1172 extension support.-
1173-
1174 \sa QAbstractFileEngine::extension()-
1175*/-
1176-
1177/*!-
1178 \class QAbstractFileEngine::ExtensionReturn-
1179 \inmodule QtCore-
1180 \since 4.3-
1181 \brief provides an extended output argument to QAbstractFileEngine's-
1182 extension support.-
1183-
1184 \sa QAbstractFileEngine::extension()-
1185*/-
1186-
1187/*!-
1188 \since 4.3-
1189-
1190 This virtual function can be reimplemented in a QAbstractFileEngine-
1191 subclass to provide support for extensions. The \a option argument is-
1192 provided as input to the extension, and this function can store output-
1193 results in \a output.-
1194-
1195 The behavior of this function is determined by \a extension; see the-
1196 Extension documentation for details.-
1197-
1198 You can call supportsExtension() to check if an extension is supported by-
1199 the file engine.-
1200-
1201 By default, no extensions are supported, and this function returns \c false.-
1202-
1203 \sa supportsExtension(), Extension-
1204*/-
1205bool QAbstractFileEngine::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output)-
1206{-
1207 Q_UNUSED(extension);-
1208 Q_UNUSED(option);-
1209 Q_UNUSED(output);-
1210 return false;
never executed: return false;
0
1211}-
1212-
1213/*!-
1214 \since 4.3-
1215-
1216 This virtual function returns \c true if the file engine supports \a-
1217 extension; otherwise, false is returned. By default, no extensions are-
1218 supported.-
1219-
1220 \sa extension()-
1221*/-
1222bool QAbstractFileEngine::supportsExtension(Extension extension) const-
1223{-
1224 Q_UNUSED(extension);-
1225 return false;
never executed: return false;
0
1226}-
1227-
1228/*!-
1229 Returns the QFile::FileError that resulted from the last failed-
1230 operation. If QFile::UnspecifiedError is returned, QFile will-
1231 use its own idea of the error status.-
1232-
1233 \sa QFile::FileError, errorString()-
1234 */-
1235QFile::FileError QAbstractFileEngine::error() const-
1236{-
1237 Q_D(const QAbstractFileEngine);-
1238 return d->fileError;
executed 3754 times by 53 tests: return d->fileError;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDateTime
  • tst_QDir
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QGlobal
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLabel
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPixmap
  • ...
3754
1239}-
1240-
1241/*!-
1242 Returns the human-readable message appropriate to the current error-
1243 reported by error(). If no suitable string is available, an-
1244 empty string is returned.-
1245-
1246 \sa error()-
1247 */-
1248QString QAbstractFileEngine::errorString() const-
1249{-
1250 Q_D(const QAbstractFileEngine);-
1251 return d->errorString;
executed 4349 times by 63 tests: return d->errorString;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDateTime
  • tst_QDir
  • tst_QDirIterator
  • tst_QDirModel
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFileInfo
  • tst_QFileSystemWatcher
  • tst_QGlobal
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QIODevice
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLabel
  • tst_QLocalSocket
  • ...
4349
1252}-
1253-
1254/*!-
1255 Sets the error type to \a error, and the error string to \a errorString.-
1256 Call this function to set the error values returned by the higher-level-
1257 classes.-
1258-
1259 \sa QFile::error(), QIODevice::errorString(), QIODevice::setErrorString()-
1260*/-
1261void QAbstractFileEngine::setError(QFile::FileError error, const QString &errorString)-
1262{-
1263 Q_D(QAbstractFileEngine);-
1264 d->fileError = error;-
1265 d->errorString = errorString;-
1266}
executed 6409 times by 71 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QApplication
  • tst_QColorDialog
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDateTime
  • tst_QDir
  • tst_QDirIterator
  • tst_QDirModel
  • tst_QDnsLookup_Appless
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGlobal
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QIODevice
  • tst_QIcon
  • ...
6409
1267-
1268QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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