OpenCoverage

qtemporarydir.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qtemporarydir.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtCore module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qtemporarydir.h"-
42-
43#ifndef QT_NO_TEMPORARYFILE-
44-
45#include "qdiriterator.h"-
46#include "qplatformdefs.h"-
47#include <QDebug>-
48#include <QPair>-
49-
50#if defined(QT_BUILD_CORE_LIB)-
51#include "qcoreapplication.h"-
52#endif-
53-
54#if !defined(Q_OS_QNX) && !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY)-
55# define USE_SYSTEM_MKDTEMP-
56#endif-
57-
58#include <stdlib.h> // mkdtemp-
59#ifndef USE_SYSTEM_MKDTEMP-
60#include <private/qfilesystemengine_p.h>-
61#endif-
62-
63#if !defined(Q_OS_WIN)-
64#include <errno.h>-
65#endif-
66-
67QT_BEGIN_NAMESPACE-
68-
69//************* QTemporaryDirPrivate-
70class QTemporaryDirPrivate-
71{-
72public:-
73 QTemporaryDirPrivate();-
74 ~QTemporaryDirPrivate();-
75-
76 void create(const QString &templateName);-
77-
78 QString pathOrError;-
79 bool autoRemove;-
80 bool success;-
81};-
82-
83QTemporaryDirPrivate::QTemporaryDirPrivate()-
84 : autoRemove(true),-
85 success(false)-
86{-
87}
executed 1210 times by 29 tests: end of block
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDir
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • ...
1210
88-
89QTemporaryDirPrivate::~QTemporaryDirPrivate()-
90{-
91}-
92-
93static QString defaultTemplateName()-
94{-
95 QString baseName;-
96#if defined(QT_BUILD_CORE_LIB)-
97 baseName = QCoreApplication::applicationName();-
98 if (baseName.isEmpty())
baseName.isEmpty()Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
FALSEevaluated 81 times by 18 tests
Evaluated by:
  • tst_QDataStream
  • tst_QFileInfo
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QMimeDatabase
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlThread
  • tst_QTemporaryDir
2-81
99#endif-
100 baseName = QLatin1String("qt_temp");
executed 2 times by 2 tests: baseName = QLatin1String("qt_temp");
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
2
101-
102 return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX");
executed 83 times by 20 tests: return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX");
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QDataStream
  • tst_QFileInfo
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QMimeDatabase
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlThread
  • tst_QTemporaryDir
83
103}-
104-
105#ifndef USE_SYSTEM_MKDTEMP-
106static int nextRand(int &v)-
107{-
108 int r = v % 62;-
109 v /= 62;-
110 if (v < 62)-
111 v = qrand();-
112 return r;-
113}-
114-
115QPair<QString, bool> q_mkdtemp(QString templateName)-
116{-
117 Q_ASSERT(templateName.endsWith(QLatin1String("XXXXXX")));-
118-
119 static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";-
120-
121 const int length = templateName.size();-
122-
123 QChar *XXXXXX = templateName.data() + length - 6;-
124-
125 for (int i = 0; i < 256; ++i) {-
126 int v = qrand();-
127-
128 /* Fill in the random bits. */-
129 XXXXXX[0] = QLatin1Char(letters[nextRand(v)]);-
130 XXXXXX[1] = QLatin1Char(letters[nextRand(v)]);-
131 XXXXXX[2] = QLatin1Char(letters[nextRand(v)]);-
132 XXXXXX[3] = QLatin1Char(letters[nextRand(v)]);-
133 XXXXXX[4] = QLatin1Char(letters[nextRand(v)]);-
134 XXXXXX[5] = QLatin1Char(letters[v % 62]);-
135-
136 QFileSystemEntry fileSystemEntry(templateName);-
137 if (QFileSystemEngine::createDirectory(fileSystemEntry, false)) {-
138 QSystemError error;-
139 QFileSystemEngine::setPermissions(fileSystemEntry,-
140 QFile::ReadOwner |-
141 QFile::WriteOwner |-
142 QFile::ExeOwner, error);-
143 if (error.error() != 0) {-
144 if (!QFileSystemEngine::removeDirectory(fileSystemEntry, false))-
145 qWarning() << "Unable to remove unused directory" << templateName;-
146 continue;-
147 }-
148 return qMakePair(templateName, true);-
149 }-
150# ifdef Q_OS_WIN-
151 const int exists = ERROR_ALREADY_EXISTS;-
152 int code = GetLastError();-
153# else-
154 const int exists = EEXIST;-
155 int code = errno;-
156# endif-
157 if (code != exists)-
158 return qMakePair(qt_error_string(code), false);-
159 }-
160 return qMakePair(qt_error_string(), false);-
161}-
162-
163#else // !USE_SYSTEM_MKDTEMP-
164-
165QPair<QString, bool> q_mkdtemp(char *templateName)-
166{-
167 bool ok = (mkdtemp(templateName) != 0);-
168 return qMakePair(ok ? QFile::decodeName(templateName) : qt_error_string(), ok);
executed 1210 times by 29 tests: return qMakePair(ok ? QFile::decodeName(templateName) : qt_error_string(), ok);
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDir
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • ...
1210
169}-
170-
171#endif // USE_SYSTEM_MKDTEMP-
172-
173void QTemporaryDirPrivate::create(const QString &templateName)-
174{-
175#ifndef USE_SYSTEM_MKDTEMP-
176 QString buffer = templateName;-
177 if (!buffer.endsWith(QLatin1String("XXXXXX")))-
178 buffer += QLatin1String("XXXXXX");-
179 const QPair<QString, bool> result = q_mkdtemp(buffer);-
180#else // !USE_SYSTEM_MKDTEMP-
181 QByteArray buffer = QFile::encodeName(templateName);-
182 if (!buffer.endsWith("XXXXXX"))
!buffer.endsWith("XXXXXX")Description
TRUEevaluated 35 times by 3 tests
Evaluated by:
  • tst_QLocalSocket
  • tst_QNetworkReply
  • tst_QTemporaryDir
FALSEevaluated 1175 times by 27 tests
Evaluated by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDir
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QMimeDatabase
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlThread
  • tst_QTemporaryDir
  • ...
35-1175
183 buffer += "XXXXXX";
executed 35 times by 3 tests: buffer += "XXXXXX";
Executed by:
  • tst_QLocalSocket
  • tst_QNetworkReply
  • tst_QTemporaryDir
35
184 QPair<QString, bool> result = q_mkdtemp(buffer.data()); // modifies buffer-
185#endif // USE_SYSTEM_MKDTEMP-
186 pathOrError = result.first;-
187 success = result.second;-
188}
executed 1210 times by 29 tests: end of block
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDir
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • ...
1210
189-
190//************* QTemporaryDir-
191-
192/*!-
193 \class QTemporaryDir-
194 \inmodule QtCore-
195 \reentrant-
196 \brief The QTemporaryDir class creates a unique directory for temporary use.-
197-
198 \ingroup io-
199-
200-
201 QTemporaryDir is used to create unique temporary dirs safely.-
202 The dir itself is created by the constructor. The name of the-
203 temporary directory is guaranteed to be unique (i.e., you are-
204 guaranteed to not overwrite an existing dir), and the directory will-
205 subsequently be removed upon destruction of the QTemporaryDir-
206 object. The directory name is either auto-generated, or created based-
207 on a template, which is passed to QTemporaryDir's constructor.-
208-
209 Example:-
210-
211 \snippet code/src_corelib_io_qtemporarydir.cpp 0-
212-
213 It is very important to test that the temporary directory could be-
214 created, using isValid(). Do not use \l {QDir::exists()}{exists()}, since a default-constructed-
215 QDir represents the current directory, which exists.-
216-
217 The path to the temporary dir can be found by calling path().-
218-
219 A temporary directory will have some static part of the name and some-
220 part that is calculated to be unique. The default path will be-
221 determined from QCoreApplication::applicationName() (otherwise \c qt_temp) and will-
222 be placed into the temporary path as returned by QDir::tempPath().-
223 If you specify your own path, a relative path will not be placed in the-
224 temporary directory by default, but be relative to the current working directory.-
225 In all cases, a random string will be appended to the path in order to make it unique.-
226-
227 \sa QDir::tempPath(), QDir, QTemporaryFile-
228*/-
229-
230/*!-
231 Constructs a QTemporaryDir using as template the application name-
232 returned by QCoreApplication::applicationName() (otherwise \c qt_temp).-
233 The directory is stored in the system's temporary directory, QDir::tempPath().-
234-
235 \sa QDir::tempPath()-
236*/-
237QTemporaryDir::QTemporaryDir()-
238 : d_ptr(new QTemporaryDirPrivate)-
239{-
240 d_ptr->create(defaultTemplateName());-
241}
executed 82 times by 20 tests: end of block
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QDataStream
  • tst_QFileInfo
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QMimeDatabase
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlThread
  • tst_QTemporaryDir
82
242-
243/*!-
244 Constructs a QTemporaryDir with a template of \a templatePath.-
245-
246 If \a templatePath is a relative path, the path will be relative to the-
247 current working directory. You can use QDir::tempPath() to construct \a-
248 templatePath if you want use the system's temporary directory.-
249-
250 If the \a templatePath ends with XXXXXX it will be used as the dynamic portion-
251 of the directory name, otherwise it will be appended.-
252 Unlike QTemporaryFile, XXXXXX in the middle of the template string is not supported.-
253-
254 \sa QDir::tempPath()-
255*/-
256QTemporaryDir::QTemporaryDir(const QString &templatePath)-
257 : d_ptr(new QTemporaryDirPrivate)-
258{-
259 if (templatePath.isEmpty())
templatePath.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QTemporaryDir
FALSEevaluated 1127 times by 11 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QLocalSocket
  • tst_QNetworkReply
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
1-1127
260 d_ptr->create(defaultTemplateName());
executed 1 time by 1 test: d_ptr->create(defaultTemplateName());
Executed by:
  • tst_QTemporaryDir
1
261 else-
262 d_ptr->create(templatePath);
executed 1127 times by 11 tests: d_ptr->create(templatePath);
Executed by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QLocalSocket
  • tst_QNetworkReply
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
1127
263}-
264-
265/*!-
266 Destroys the temporary directory object.-
267 If auto remove mode was set, it will automatically delete the directory-
268 including all its contents.-
269-
270 \sa autoRemove()-
271*/-
272QTemporaryDir::~QTemporaryDir()-
273{-
274 if (d_ptr->autoRemove)
d_ptr->autoRemoveDescription
TRUEevaluated 230 times by 47 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
  • tst_largefile - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qdatastream - unknown status
  • tst_qfile - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileinfo - unknown status
  • ...
FALSEevaluated 1001 times by 1 test
Evaluated by:
  • tst_QTemporaryDir
230-1001
275 remove();
executed 230 times by 47 tests: remove();
Executed by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
  • tst_largefile - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qdatastream - unknown status
  • tst_qfile - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileinfo - unknown status
  • ...
230
276}
executed 1231 times by 47 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
  • tst_largefile - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qdatastream - unknown status
  • tst_qfile - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileinfo - unknown status
  • ...
1231
277-
278/*!-
279 Returns \c true if the QTemporaryDir was created successfully.-
280*/-
281bool QTemporaryDir::isValid() const-
282{-
283 return d_ptr->success;
executed 1237 times by 37 tests: return d_ptr->success;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPixmap
  • tst_QProcess
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QSqlDatabase
  • ...
1237
284}-
285-
286/*!-
287 \since 5.6-
288-
289 If isValid() returns \c false, this function returns the error string that-
290 explains why the creation of the temporary directory failed. Otherwise, this-
291 function return an empty string.-
292*/-
293QString QTemporaryDir::errorString() const-
294{-
295 return d_ptr->success ? QString() : d_ptr->pathOrError;
executed 1100 times by 23 tests: return d_ptr->success ? QString() : d_ptr->pathOrError;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QPixmap
  • tst_QProcess
  • tst_QSaveFile
  • tst_QTemporaryDir
  • tst_QTemporaryFile
  • tst_QTextStream
  • tst_Selftests
  • tst_languageChange
  • tst_qstandardpaths
  • tst_uic
1100
296}-
297-
298/*!-
299 Returns the path to the temporary directory.-
300 Empty if the QTemporaryDir could not be created.-
301*/-
302QString QTemporaryDir::path() const-
303{-
304 return d_ptr->success ? d_ptr->pathOrError : QString();
executed 5034 times by 69 tests: return d_ptr->success ? d_ptr->pathOrError : QString();
Executed by:
  • tst_LargeFile
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIODevice
  • tst_QIcon
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QLockFile
  • tst_QMimeDatabase
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QPixmap
  • tst_QProcess
  • tst_QSaveFile
  • ...
5034
305}-
306-
307/*!-
308 Returns \c true if the QTemporaryDir is in auto remove-
309 mode. Auto-remove mode will automatically delete the directory from-
310 disk upon destruction. This makes it very easy to create your-
311 QTemporaryDir object on the stack, fill it with files, do something with-
312 the files, and finally on function return it will automatically clean up-
313 after itself.-
314-
315 Auto-remove is on by default.-
316-
317 \sa setAutoRemove(), remove()-
318*/-
319bool QTemporaryDir::autoRemove() const-
320{-
321 return d_ptr->autoRemove;
executed 2 times by 1 test: return d_ptr->autoRemove;
Executed by:
  • tst_QTemporaryDir
2
322}-
323-
324/*!-
325 Sets the QTemporaryDir into auto-remove mode if \a b is true.-
326-
327 Auto-remove is on by default.-
328-
329 \sa autoRemove(), remove()-
330*/-
331void QTemporaryDir::setAutoRemove(bool b)-
332{-
333 d_ptr->autoRemove = b;-
334}
executed 1009 times by 4 tests: end of block
Executed by:
  • tst_QFileInfo
  • tst_QNetworkReply
  • tst_QTemporaryDir
  • tst_languageChange
1009
335-
336/*!-
337 Removes the temporary directory, including all its contents.-
338-
339 Returns \c true if removing was successful.-
340*/-
341bool QTemporaryDir::remove()-
342{-
343 if (!d_ptr->success)
!d_ptr->successDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QTemporaryDir
FALSEevaluated 226 times by 47 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
  • tst_largefile - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qdatastream - unknown status
  • tst_qfile - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileinfo - unknown status
  • ...
7-226
344 return false;
executed 7 times by 1 test: return false;
Executed by:
  • tst_QTemporaryDir
7
345 Q_ASSERT(!path().isEmpty());-
346 Q_ASSERT(path() != QLatin1String("."));-
347-
348 const bool result = QDir(path()).removeRecursively();-
349 if (!result) {
!resultDescription
TRUEnever evaluated
FALSEevaluated 226 times by 47 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
  • tst_largefile - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qdatastream - unknown status
  • tst_qfile - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileinfo - unknown status
  • ...
0-226
350 qWarning() << "QTemporaryDir: Unable to remove"-
351 << QDir::toNativeSeparators(path())-
352 << "most likely due to the presence of read-only files.";-
353 }
never executed: end of block
0
354 return result;
executed 226 times by 47 tests: return result;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QAbstractNetworkCache
  • tst_QCompleter
  • tst_QDir
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QIcon
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QLocalSocket
  • tst_QMimeDatabase
  • tst_QNetworkReply
  • tst_QSaveFile
  • tst_QSharedPointer
  • tst_QSql
  • tst_QTemporaryDir
  • tst_QXmlStream
  • tst_languageChange
  • tst_largefile - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qdatastream - unknown status
  • tst_qfile - unknown status
  • tst_qfiledialog2 - unknown status
  • tst_qfileinfo - unknown status
  • ...
226
355}-
356-
357QT_END_NAMESPACE-
358-
359#endif // QT_NO_TEMPORARYFILE-
Source codeSwitch to Preprocessed file

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