Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | class QTemporaryDirPrivate | - |
17 | { | - |
18 | public: | - |
19 | QTemporaryDirPrivate(); | - |
20 | ~QTemporaryDirPrivate(); | - |
21 | | - |
22 | void create(const QString &templateName); | - |
23 | | - |
24 | QString path; | - |
25 | bool autoRemove; | - |
26 | bool success; | - |
27 | }; | - |
28 | | - |
29 | QTemporaryDirPrivate::QTemporaryDirPrivate() | - |
30 | : autoRemove(true), | - |
31 | success(false) | - |
32 | { | - |
33 | } executed: } Execution Count:1148 | 1148 |
34 | | - |
35 | QTemporaryDirPrivate::~QTemporaryDirPrivate() | - |
36 | { | - |
37 | } | - |
38 | | - |
39 | static QString defaultTemplateName() | - |
40 | { | - |
41 | QString baseName; | - |
42 | | - |
43 | baseName = QCoreApplication::applicationName(); | - |
44 | if (baseName.isEmpty()) partially evaluated: baseName.isEmpty() no Evaluation Count:0 | yes Evaluation Count:1035 |
| 0-1035 |
45 | | - |
46 | baseName = QLatin1String("qt_temp"); never executed: baseName = QLatin1String("qt_temp"); | 0 |
47 | | - |
48 | return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX"); executed: return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX"); Execution Count:1035 | 1035 |
49 | } | - |
50 | void QTemporaryDirPrivate::create(const QString &templateName) | - |
51 | { | - |
52 | QByteArray buffer = QFile::encodeName(templateName); | - |
53 | if (!buffer.endsWith("XXXXXX")) evaluated: !buffer.endsWith("XXXXXX") yes Evaluation Count:34 | yes Evaluation Count:1114 |
| 34-1114 |
54 | buffer += "XXXXXX"; executed: buffer += "XXXXXX"; Execution Count:34 | 34 |
55 | if (mkdtemp(buffer.data())) { evaluated: mkdtemp(buffer.data()) yes Evaluation Count:1141 | yes Evaluation Count:7 |
| 7-1141 |
56 | success = true; | - |
57 | path = QFile::decodeName(buffer.constData()); | - |
58 | } executed: } Execution Count:1141 | 1141 |
59 | } executed: } Execution Count:1148 | 1148 |
60 | QTemporaryDir::QTemporaryDir() | - |
61 | : d_ptr(new QTemporaryDirPrivate) | - |
62 | { | - |
63 | d_ptr->create(defaultTemplateName()); | - |
64 | } executed: } Execution Count:1034 | 1034 |
65 | QTemporaryDir::QTemporaryDir(const QString &templateName) | - |
66 | : d_ptr(new QTemporaryDirPrivate) | - |
67 | { | - |
68 | if (templateName.isEmpty()) evaluated: templateName.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:113 |
| 1-113 |
69 | d_ptr->create(defaultTemplateName()); executed: d_ptr->create(defaultTemplateName()); Execution Count:1 | 1 |
70 | else | - |
71 | d_ptr->create(templateName); executed: d_ptr->create(templateName); Execution Count:113 | 113 |
72 | } | - |
73 | QTemporaryDir::~QTemporaryDir() | - |
74 | { | - |
75 | if (d_ptr->autoRemove) evaluated: d_ptr->autoRemove yes Evaluation Count:161 | yes Evaluation Count:1001 |
| 161-1001 |
76 | remove(); executed: remove(); Execution Count:161 | 161 |
77 | } executed: } Execution Count:1162 | 1162 |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | bool QTemporaryDir::isValid() const | - |
83 | { | - |
84 | return d_ptr->success; executed: return d_ptr->success; Execution Count:1149 | 1149 |
85 | } | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | QString QTemporaryDir::path() const | - |
92 | { | - |
93 | return d_ptr->path; executed: return d_ptr->path; Execution Count:3756 | 3756 |
94 | } | - |
95 | bool QTemporaryDir::autoRemove() const | - |
96 | { | - |
97 | return d_ptr->autoRemove; executed: return d_ptr->autoRemove; Execution Count:2 | 2 |
98 | } | - |
99 | void QTemporaryDir::setAutoRemove(bool b) | - |
100 | { | - |
101 | d_ptr->autoRemove = b; | - |
102 | } executed: } Execution Count:1007 | 1007 |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | bool QTemporaryDir::remove() | - |
110 | { | - |
111 | if (!d_ptr->success) evaluated: !d_ptr->success yes Evaluation Count:7 | yes Evaluation Count:156 |
| 7-156 |
112 | return false; executed: return false; Execution Count:7 | 7 |
113 | qt_noop(); | - |
114 | qt_noop(); | - |
115 | | - |
116 | return QDir(path()).removeRecursively(); executed: return QDir(path()).removeRecursively(); Execution Count:156 | 156 |
117 | } | - |
118 | | - |
119 | | - |
120 | | - |
| | |