io/qfilesystemengine_unix.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qplatformdefs.h" -
43#include "qfilesystemengine_p.h" -
44#include "qfile.h" -
45 -
46#include <QtCore/qvarlengtharray.h> -
47 -
48#include <stdlib.h> // for realpath() -
49#include <unistd.h> -
50#include <stdio.h> -
51#include <errno.h> -
52 -
53 -
54#if defined(Q_OS_MAC) -
55# include <QtCore/private/qcore_mac_p.h> -
56#endif -
57 -
58QT_BEGIN_NAMESPACE -
59 -
60#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
61static inline bool _q_isMacHidden(const char *nativePath) -
62{ -
63 OSErr err; -
64 -
65 FSRef fsRef; -
66 err = FSPathMakeRefWithOptions(reinterpret_cast<const UInt8 *>(nativePath), -
67 kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0); -
68 if (err != noErr) -
69 return false; -
70 -
71 FSCatalogInfo catInfo; -
72 err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL); -
73 if (err != noErr) -
74 return false; -
75 -
76 FileInfo * const fileInfo = reinterpret_cast<FileInfo*>(&catInfo.finderInfo); -
77 return (fileInfo->finderFlags & kIsInvisible); -
78} -
79#else -
80static inline bool _q_isMacHidden(const char *nativePath) -
81{ -
82 Q_UNUSED(nativePath);
executed (the execution status of this line is deduced): (void)nativePath;;
-
83 // no-op -
84 return false;
executed: return false;
Execution Count:17996
17996
85} -
86#endif -
87 -
88//static -
89QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data) -
90{ -
91#if defined(__GLIBC__) && !defined(PATH_MAX) -
92#define PATH_CHUNK_SIZE 256 -
93 char *s = 0; -
94 int len = -1; -
95 int size = PATH_CHUNK_SIZE; -
96 -
97 while (1) { -
98 s = (char *) ::realloc(s, size); -
99 Q_CHECK_PTR(s); -
100 len = ::readlink(link.nativeFilePath().constData(), s, size); -
101 if (len < 0) { -
102 ::free(s); -
103 break; -
104 } -
105 if (len < size) { -
106 break; -
107 } -
108 size *= 2; -
109 } -
110#else -
111 char s[PATH_MAX+1];
executed (the execution status of this line is deduced): char s[4096 +1];
-
112 int len = readlink(link.nativeFilePath().constData(), s, PATH_MAX);
executed (the execution status of this line is deduced): int len = readlink(link.nativeFilePath().constData(), s, 4096);
-
113#endif -
114 if (len > 0) {
partially evaluated: len > 0
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
115 QString ret;
executed (the execution status of this line is deduced): QString ret;
-
116 if (!data.hasFlags(QFileSystemMetaData::DirectoryType))
evaluated: !data.hasFlags(QFileSystemMetaData::DirectoryType)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
117 fillMetaData(link, data, QFileSystemMetaData::DirectoryType);
executed: fillMetaData(link, data, QFileSystemMetaData::DirectoryType);
Execution Count:6
6
118 if (data.isDirectory() && s[0] != '/') {
evaluated: data.isDirectory()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
evaluated: s[0] != '/'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-7
119 QDir parent(link.filePath());
executed (the execution status of this line is deduced): QDir parent(link.filePath());
-
120 parent.cdUp();
executed (the execution status of this line is deduced): parent.cdUp();
-
121 ret = parent.path();
executed (the execution status of this line is deduced): ret = parent.path();
-
122 if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
partially evaluated: !ret.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !ret.endsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
123 ret += QLatin1Char('/');
executed: ret += QLatin1Char('/');
Execution Count:1
1
124 }
executed: }
Execution Count:1
1
125 s[len] = '\0';
executed (the execution status of this line is deduced): s[len] = '\0';
-
126 ret += QFile::decodeName(QByteArray(s));
executed (the execution status of this line is deduced): ret += QFile::decodeName(QByteArray(s));
-
127#if defined(__GLIBC__) && !defined(PATH_MAX) -
128 ::free(s); -
129#endif -
130 -
131 if (!ret.startsWith(QLatin1Char('/'))) {
evaluated: !ret.startsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6
4-6
132 if (link.filePath().startsWith(QLatin1Char('/'))) {
evaluated: link.filePath().startsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
133 ret.prepend(link.filePath().left(link.filePath().lastIndexOf(QLatin1Char('/')))
executed (the execution status of this line is deduced): ret.prepend(link.filePath().left(link.filePath().lastIndexOf(QLatin1Char('/')))
-
134 + QLatin1Char('/'));
executed (the execution status of this line is deduced): + QLatin1Char('/'));
-
135 } else {
executed: }
Execution Count:1
1
136 ret.prepend(QDir::currentPath() + QLatin1Char('/'));
executed (the execution status of this line is deduced): ret.prepend(QDir::currentPath() + QLatin1Char('/'));
-
137 }
executed: }
Execution Count:3
3
138 } -
139 ret = QDir::cleanPath(ret);
executed (the execution status of this line is deduced): ret = QDir::cleanPath(ret);
-
140 if (ret.size() > 1 && ret.endsWith(QLatin1Char('/')))
partially evaluated: ret.size() > 1
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
partially evaluated: ret.endsWith(QLatin1Char('/'))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
141 ret.chop(1);
never executed: ret.chop(1);
0
142 return QFileSystemEntry(ret);
executed: return QFileSystemEntry(ret);
Execution Count:10
10
143 } -
144#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
145 { -
146 FSRef fref; -
147 if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) { -
148 // TODO get the meta data info from the QFileSystemMetaData object -
149 Boolean isAlias, isFolder; -
150 if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { -
151 AliasHandle alias; -
152 if (FSNewAlias(0, &fref, &alias) == noErr && alias) { -
153 QCFString cfstr; -
154 if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) -
155 return QFileSystemEntry(QCFString::toQString(cfstr)); -
156 } -
157 } -
158 } -
159 } -
160#endif -
161 return QFileSystemEntry();
never executed: return QFileSystemEntry();
0
162} -
163 -
164//static -
165QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data) -
166{ -
167 if (entry.isEmpty() || entry.isRoot())
partially evaluated: entry.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2130
evaluated: entry.isRoot()
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:2068
0-2130
168 return entry;
executed: return entry;
Execution Count:62
62
169 -
170#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX) && _POSIX_VERSION < 200809L -
171 // realpath(X,0) is not supported -
172 Q_UNUSED(data); -
173 return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); -
174#else -
175 char *ret = 0;
executed (the execution status of this line is deduced): char *ret = 0;
-
176# if defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
177 // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. -
178 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { -
179 ret = realpath(entry.nativeFilePath().constData(), (char*)0); -
180 } else { -
181 // on 10.5 we can use FSRef to resolve the file path. -
182 QString path = QDir::cleanPath(entry.filePath()); -
183 FSRef fsref; -
184 if (FSPathMakeRef((const UInt8 *)path.toUtf8().data(), &fsref, 0) == noErr) { -
185 CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref); -
186 CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle); -
187 QString ret = QCFString::toQString(canonicalPath); -
188 CFRelease(canonicalPath); -
189 CFRelease(urlref); -
190 return QFileSystemEntry(ret); -
191 } -
192 } -
193# else -
194# if _POSIX_VERSION >= 200801L -
195 ret = realpath(entry.nativeFilePath().constData(), (char*)0);
executed (the execution status of this line is deduced): ret = realpath(entry.nativeFilePath().constData(), (char*)0);
-
196# else -
197 ret = (char*)malloc(PATH_MAX + 1); -
198 if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { -
199 const int savedErrno = errno; // errno is checked below, and free() might change it -
200 free(ret); -
201 errno = savedErrno; -
202 ret = 0; -
203 } -
204# endif -
205# endif -
206 if (ret) {
evaluated: ret
TRUEFALSE
yes
Evaluation Count:2055
yes
Evaluation Count:13
13-2055
207 data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
executed (the execution status of this line is deduced): data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
-
208 data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
executed (the execution status of this line is deduced): data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
-
209 QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
executed (the execution status of this line is deduced): QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
-
210 free(ret);
executed (the execution status of this line is deduced): free(ret);
-
211 return QFileSystemEntry(canonicalPath);
executed: return QFileSystemEntry(canonicalPath);
Execution Count:2055
2055
212 } else if (errno == ENOENT) { // file doesn't exist
partially evaluated: (*__errno_location ()) == 2
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
213 data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
executed (the execution status of this line is deduced): data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
-
214 data.entryFlags &= ~(QFileSystemMetaData::ExistsAttribute);
executed (the execution status of this line is deduced): data.entryFlags &= ~(QFileSystemMetaData::ExistsAttribute);
-
215 return QFileSystemEntry();
executed: return QFileSystemEntry();
Execution Count:13
13
216 } -
217 return entry;
never executed: return entry;
0
218#endif -
219} -
220 -
221//static -
222QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) -
223{ -
224 if (entry.isAbsolute() && entry.isClean())
evaluated: entry.isAbsolute()
TRUEFALSE
yes
Evaluation Count:8268
yes
Evaluation Count:542
evaluated: entry.isClean()
TRUEFALSE
yes
Evaluation Count:7883
yes
Evaluation Count:385
385-8268
225 return entry;
executed: return entry;
Execution Count:7883
7883
226 -
227 QByteArray orig = entry.nativeFilePath();
executed (the execution status of this line is deduced): QByteArray orig = entry.nativeFilePath();
-
228 QByteArray result;
executed (the execution status of this line is deduced): QByteArray result;
-
229 if (orig.isEmpty() || !orig.startsWith('/')) {
partially evaluated: orig.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:927
evaluated: !orig.startsWith('/')
TRUEFALSE
yes
Evaluation Count:542
yes
Evaluation Count:385
0-927
230 QFileSystemEntry cur(currentPath());
executed (the execution status of this line is deduced): QFileSystemEntry cur(currentPath());
-
231 result = cur.nativeFilePath();
executed (the execution status of this line is deduced): result = cur.nativeFilePath();
-
232 }
executed: }
Execution Count:542
542
233 if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) {
partially evaluated: !orig.isEmpty()
TRUEFALSE
yes
Evaluation Count:927
no
Evaluation Count:0
evaluated: orig.length() == 1
TRUEFALSE
yes
Evaluation Count:186
yes
Evaluation Count:741
partially evaluated: orig[0] == '.'
TRUEFALSE
yes
Evaluation Count:186
no
Evaluation Count:0
0-927
234 if (!result.isEmpty() && !result.endsWith('/'))
evaluated: !result.isEmpty()
TRUEFALSE
yes
Evaluation Count:356
yes
Evaluation Count:385
partially evaluated: !result.endsWith('/')
TRUEFALSE
yes
Evaluation Count:356
no
Evaluation Count:0
0-385
235 result.append('/');
executed: result.append('/');
Execution Count:356
356
236 result.append(orig);
executed (the execution status of this line is deduced): result.append(orig);
-
237 }
executed: }
Execution Count:741
741
238 -
239 if (result.length() == 1 && result[0] == '/')
partially evaluated: result.length() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:927
never evaluated: result[0] == '/'
0-927
240 return QFileSystemEntry(result, QFileSystemEntry::FromNativePath());
never executed: return QFileSystemEntry(result, QFileSystemEntry::FromNativePath());
0
241 const bool isDir = result.endsWith('/');
executed (the execution status of this line is deduced): const bool isDir = result.endsWith('/');
-
242 -
243 /* as long as QDir::cleanPath() operates on a QString we have to convert to a string here. -
244 * ideally we never convert to a string since that loses information. Please fix after -
245 * we get a QByteArray version of QDir::cleanPath() -
246 */ -
247 QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath());
executed (the execution status of this line is deduced): QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath());
-
248 QString stringVersion = QDir::cleanPath(resultingEntry.filePath());
executed (the execution status of this line is deduced): QString stringVersion = QDir::cleanPath(resultingEntry.filePath());
-
249 if (isDir)
evaluated: isDir
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:925
2-925
250 stringVersion.append(QLatin1Char('/'));
executed: stringVersion.append(QLatin1Char('/'));
Execution Count:2
2
251 return QFileSystemEntry(stringVersion);
executed: return QFileSystemEntry(stringVersion);
Execution Count:927
927
252} -
253 -
254//static -
255QString QFileSystemEngine::resolveUserName(uint userId) -
256{ -
257#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) -
258 int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
executed (the execution status of this line is deduced): int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
-
259 if (size_max == -1)
partially evaluated: size_max == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
260 size_max = 1024;
never executed: size_max = 1024;
0
261 QVarLengthArray<char, 1024> buf(size_max);
executed (the execution status of this line is deduced): QVarLengthArray<char, 1024> buf(size_max);
-
262#endif -
263 -
264 struct passwd *pw = 0;
executed (the execution status of this line is deduced): struct passwd *pw = 0;
-
265#if !defined(Q_OS_INTEGRITY) -
266#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) -
267 struct passwd entry;
executed (the execution status of this line is deduced): struct passwd entry;
-
268 getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw);
executed (the execution status of this line is deduced): getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw);
-
269#else -
270 pw = getpwuid(userId); -
271#endif -
272#endif -
273 if (pw)
partially evaluated: pw
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
274 return QFile::decodeName(QByteArray(pw->pw_name));
executed: return QFile::decodeName(QByteArray(pw->pw_name));
Execution Count:2
2
275 return QString();
never executed: return QString();
0
276} -
277 -
278//static -
279QString QFileSystemEngine::resolveGroupName(uint groupId) -
280{ -
281#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) -
282 int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
never executed (the execution status of this line is deduced): int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
-
283 if (size_max == -1)
never evaluated: size_max == -1
0
284 size_max = 1024;
never executed: size_max = 1024;
0
285 QVarLengthArray<char, 1024> buf(size_max);
never executed (the execution status of this line is deduced): QVarLengthArray<char, 1024> buf(size_max);
-
286#endif -
287 -
288 struct group *gr = 0;
never executed (the execution status of this line is deduced): struct group *gr = 0;
-
289#if !defined(Q_OS_INTEGRITY) -
290#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) -
291 size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
never executed (the execution status of this line is deduced): size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
-
292 if (size_max == -1)
never evaluated: size_max == -1
0
293 size_max = 1024;
never executed: size_max = 1024;
0
294 buf.resize(size_max);
never executed (the execution status of this line is deduced): buf.resize(size_max);
-
295 struct group entry;
never executed (the execution status of this line is deduced): struct group entry;
-
296 // Some large systems have more members than the POSIX max size -
297 // Loop over by doubling the buffer size (upper limit 250k) -
298 for (unsigned size = size_max; size < 256000; size += size)
never evaluated: size < 256000
0
299 { -
300 buf.resize(size);
never executed (the execution status of this line is deduced): buf.resize(size);
-
301 // ERANGE indicates that the buffer was too small -
302 if (!getgrgid_r(groupId, &entry, buf.data(), buf.size(), &gr)
never evaluated: !getgrgid_r(groupId, &entry, buf.data(), buf.size(), &gr)
0
303 || errno != ERANGE)
never evaluated: (*__errno_location ()) != 34
0
304 break;
never executed: break;
0
305 }
never executed: }
0
306#else -
307 gr = getgrgid(groupId); -
308#endif -
309#endif -
310 if (gr)
never evaluated: gr
0
311 return QFile::decodeName(QByteArray(gr->gr_name));
never executed: return QFile::decodeName(QByteArray(gr->gr_name));
0
312 return QString();
never executed: return QString();
0
313} -
314 -
315#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
316//static -
317QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) -
318{ -
319 QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(entry.filePath()), -
320 kCFURLPOSIXPathStyle, true); -
321 if (QCFType<CFDictionaryRef> dict = CFBundleCopyInfoDictionaryForURL(url)) { -
322 if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) { -
323 if (CFGetTypeID(name) == CFStringGetTypeID()) -
324 return QCFString::toQString((CFStringRef)name); -
325 } -
326 } -
327 return QString(); -
328} -
329#endif -
330 -
331//static -
332bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, -
333 QFileSystemMetaData::MetaDataFlags what) -
334{ -
335#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
336 if (what & QFileSystemMetaData::BundleType) { -
337 if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) -
338 what |= QFileSystemMetaData::DirectoryType; -
339 } -
340# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -
341 if (what & QFileSystemMetaData::HiddenAttribute) { -
342 // Mac OS >= 10.5: st_flags & UF_HIDDEN -
343 what |= QFileSystemMetaData::PosixStatFlags; -
344 } -
345# endif // MAC_OS_X_VERSION_MAX_ALLOWED... -
346#endif // defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
347 -
348 if (what & QFileSystemMetaData::PosixStatFlags)
evaluated: what & QFileSystemMetaData::PosixStatFlags
TRUEFALSE
yes
Evaluation Count:15994
yes
Evaluation Count:31216
15994-31216
349 what |= QFileSystemMetaData::PosixStatFlags;
executed: what |= QFileSystemMetaData::PosixStatFlags;
Execution Count:15994
15994
350 -
351 if (what & QFileSystemMetaData::ExistsAttribute) {
evaluated: what & QFileSystemMetaData::ExistsAttribute
TRUEFALSE
yes
Evaluation Count:13214
yes
Evaluation Count:33996
13214-33996
352 // FIXME: Would other queries being performed provide this bit? -
353 what |= QFileSystemMetaData::PosixStatFlags;
executed (the execution status of this line is deduced): what |= QFileSystemMetaData::PosixStatFlags;
-
354 }
executed: }
Execution Count:13214
13214
355 -
356 data.entryFlags &= ~what;
executed (the execution status of this line is deduced): data.entryFlags &= ~what;
-
357 -
358 const char * nativeFilePath;
executed (the execution status of this line is deduced): const char * nativeFilePath;
-
359 int nativeFilePathLength;
executed (the execution status of this line is deduced): int nativeFilePathLength;
-
360 { -
361 const QByteArray &path = entry.nativeFilePath();
executed (the execution status of this line is deduced): const QByteArray &path = entry.nativeFilePath();
-
362 nativeFilePath = path.constData();
executed (the execution status of this line is deduced): nativeFilePath = path.constData();
-
363 nativeFilePathLength = path.size();
executed (the execution status of this line is deduced): nativeFilePathLength = path.size();
-
364 Q_UNUSED(nativeFilePathLength);
executed (the execution status of this line is deduced): (void)nativeFilePathLength;;
-
365 } -
366 -
367 bool entryExists = true; // innocent until proven otherwise
executed (the execution status of this line is deduced): bool entryExists = true;
-
368 -
369 QT_STATBUF statBuffer;
executed (the execution status of this line is deduced): struct stat64 statBuffer;
-
370 bool statBufferValid = false;
executed (the execution status of this line is deduced): bool statBufferValid = false;
-
371 if (what & QFileSystemMetaData::LinkType) {
evaluated: what & QFileSystemMetaData::LinkType
TRUEFALSE
yes
Evaluation Count:7149
yes
Evaluation Count:40062
7149-40062
372 if (QT_LSTAT(nativeFilePath, &statBuffer) == 0) {
evaluated: ::lstat64(nativeFilePath, &statBuffer) == 0
TRUEFALSE
yes
Evaluation Count:3995
yes
Evaluation Count:3154
3154-3995
373 if (S_ISLNK(statBuffer.st_mode)) {
evaluated: ((((statBuffer.st_mode)) & 0170000) == (0120000))
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:3931
64-3931
374 data.entryFlags |= QFileSystemMetaData::LinkType;
executed (the execution status of this line is deduced): data.entryFlags |= QFileSystemMetaData::LinkType;
-
375 } else {
executed: }
Execution Count:64
64
376 statBufferValid = true;
executed (the execution status of this line is deduced): statBufferValid = true;
-
377 data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags;
executed (the execution status of this line is deduced): data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags;
-
378 }
executed: }
Execution Count:3931
3931
379 } else { -
380 entryExists = false;
executed (the execution status of this line is deduced): entryExists = false;
-
381 }
executed: }
Execution Count:3154
3154
382 -
383 data.knownFlagsMask |= QFileSystemMetaData::LinkType;
executed (the execution status of this line is deduced): data.knownFlagsMask |= QFileSystemMetaData::LinkType;
-
384 }
executed: }
Execution Count:7149
7149
385 -
386 if (statBufferValid || (what & QFileSystemMetaData::PosixStatFlags)) {
evaluated: statBufferValid
TRUEFALSE
yes
Evaluation Count:3931
yes
Evaluation Count:43280
evaluated: (what & QFileSystemMetaData::PosixStatFlags)
TRUEFALSE
yes
Evaluation Count:24835
yes
Evaluation Count:18445
3931-43280
387 if (entryExists && !statBufferValid)
evaluated: entryExists
TRUEFALSE
yes
Evaluation Count:25612
yes
Evaluation Count:3154
evaluated: !statBufferValid
TRUEFALSE
yes
Evaluation Count:21681
yes
Evaluation Count:3931
3154-25612
388 statBufferValid = (QT_STAT(nativeFilePath, &statBuffer) == 0);
executed: statBufferValid = (::stat64(nativeFilePath, &statBuffer) == 0);
Execution Count:21681
21681
389 -
390 if (statBufferValid)
evaluated: statBufferValid
TRUEFALSE
yes
Evaluation Count:20383
yes
Evaluation Count:8383
8383-20383
391 data.fillFromStatBuf(statBuffer);
executed: data.fillFromStatBuf(statBuffer);
Execution Count:20383
20383
392 else { -
393 entryExists = false;
executed (the execution status of this line is deduced): entryExists = false;
-
394 data.creationTime_ = 0;
executed (the execution status of this line is deduced): data.creationTime_ = 0;
-
395 data.modificationTime_ = 0;
executed (the execution status of this line is deduced): data.modificationTime_ = 0;
-
396 data.accessTime_ = 0;
executed (the execution status of this line is deduced): data.accessTime_ = 0;
-
397 data.size_ = 0;
executed (the execution status of this line is deduced): data.size_ = 0;
-
398 data.userId_ = (uint) -2;
executed (the execution status of this line is deduced): data.userId_ = (uint) -2;
-
399 data.groupId_ = (uint) -2;
executed (the execution status of this line is deduced): data.groupId_ = (uint) -2;
-
400 }
executed: }
Execution Count:8383
8383
401 -
402 // reset the mask -
403 data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags
executed (the execution status of this line is deduced): data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags
-
404 | QFileSystemMetaData::ExistsAttribute;
executed (the execution status of this line is deduced): | QFileSystemMetaData::ExistsAttribute;
-
405 }
executed: }
Execution Count:28765
28765
406 -
407#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
408 if (what & QFileSystemMetaData::AliasType) -
409 { -
410 if (entryExists) { -
411 FSRef fref; -
412 if (FSPathMakeRef((const UInt8 *)nativeFilePath, &fref, NULL) == noErr) { -
413 Boolean isAlias, isFolder; -
414 if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr) { -
415 if (isAlias) -
416 data.entryFlags |= QFileSystemMetaData::AliasType; -
417 } -
418 } -
419 } -
420 data.knownFlagsMask |= QFileSystemMetaData::AliasType; -
421 } -
422#endif -
423 -
424 if (what & QFileSystemMetaData::UserPermissions) {
evaluated: what & QFileSystemMetaData::UserPermissions
TRUEFALSE
yes
Evaluation Count:2590
yes
Evaluation Count:44620
2590-44620
425 // calculate user permissions -
426 -
427 if (entryExists) {
partially evaluated: entryExists
TRUEFALSE
yes
Evaluation Count:2590
no
Evaluation Count:0
0-2590
428 if (what & QFileSystemMetaData::UserReadPermission) {
evaluated: what & QFileSystemMetaData::UserReadPermission
TRUEFALSE
yes
Evaluation Count:2571
yes
Evaluation Count:19
19-2571
429 if (QT_ACCESS(nativeFilePath, R_OK) == 0)
evaluated: ::access(nativeFilePath, 4) == 0
TRUEFALSE
yes
Evaluation Count:2525
yes
Evaluation Count:46
46-2525
430 data.entryFlags |= QFileSystemMetaData::UserReadPermission;
executed: data.entryFlags |= QFileSystemMetaData::UserReadPermission;
Execution Count:2525
2525
431 }
executed: }
Execution Count:2571
2571
432 if (what & QFileSystemMetaData::UserWritePermission) {
evaluated: what & QFileSystemMetaData::UserWritePermission
TRUEFALSE
yes
Evaluation Count:2473
yes
Evaluation Count:117
117-2473
433 if (QT_ACCESS(nativeFilePath, W_OK) == 0)
evaluated: ::access(nativeFilePath, 2) == 0
TRUEFALSE
yes
Evaluation Count:1954
yes
Evaluation Count:519
519-1954
434 data.entryFlags |= QFileSystemMetaData::UserWritePermission;
executed: data.entryFlags |= QFileSystemMetaData::UserWritePermission;
Execution Count:1954
1954
435 }
executed: }
Execution Count:2473
2473
436 if (what & QFileSystemMetaData::UserExecutePermission) {
evaluated: what & QFileSystemMetaData::UserExecutePermission
TRUEFALSE
yes
Evaluation Count:2478
yes
Evaluation Count:112
112-2478
437 if (QT_ACCESS(nativeFilePath, X_OK) == 0)
evaluated: ::access(nativeFilePath, 1) == 0
TRUEFALSE
yes
Evaluation Count:1737
yes
Evaluation Count:741
741-1737
438 data.entryFlags |= QFileSystemMetaData::UserExecutePermission;
executed: data.entryFlags |= QFileSystemMetaData::UserExecutePermission;
Execution Count:1737
1737
439 }
executed: }
Execution Count:2478
2478
440 }
executed: }
Execution Count:2590
2590
441 data.knownFlagsMask |= (what & QFileSystemMetaData::UserPermissions);
executed (the execution status of this line is deduced): data.knownFlagsMask |= (what & QFileSystemMetaData::UserPermissions);
-
442 }
executed: }
Execution Count:2590
2590
443 -
444 if (what & QFileSystemMetaData::HiddenAttribute
evaluated: what & QFileSystemMetaData::HiddenAttribute
TRUEFALSE
yes
Evaluation Count:22879
yes
Evaluation Count:24331
22879-24331
445 && !data.isHidden()) {
partially evaluated: !data.isHidden()
TRUEFALSE
yes
Evaluation Count:22879
no
Evaluation Count:0
0-22879
446 QString fileName = entry.fileName();
executed (the execution status of this line is deduced): QString fileName = entry.fileName();
-
447 if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.'))
partially evaluated: fileName.size() > 0
TRUEFALSE
yes
Evaluation Count:22879
no
Evaluation Count:0
evaluated: fileName.at(0) == QLatin1Char('.')
TRUEFALSE
yes
Evaluation Count:1729
yes
Evaluation Count:21150
0-22879
448 || (entryExists && _q_isMacHidden(nativeFilePath)))
evaluated: entryExists
TRUEFALSE
yes
Evaluation Count:17996
yes
Evaluation Count:3154
partially evaluated: _q_isMacHidden(nativeFilePath)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17996
0-17996
449 data.entryFlags |= QFileSystemMetaData::HiddenAttribute;
executed: data.entryFlags |= QFileSystemMetaData::HiddenAttribute;
Execution Count:1729
1729
450 data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
executed (the execution status of this line is deduced): data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
-
451 }
executed: }
Execution Count:22879
22879
452 -
453#if defined(Q_OS_MAC) && !defined(Q_OS_IOS) -
454 if (what & QFileSystemMetaData::BundleType) { -
455 if (entryExists && data.isDirectory()) { -
456 QCFType<CFStringRef> path = CFStringCreateWithBytes(0, -
457 (const UInt8*)nativeFilePath, nativeFilePathLength, -
458 kCFStringEncodingUTF8, false); -
459 QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path, -
460 kCFURLPOSIXPathStyle, true); -
461 -
462 UInt32 type, creator; -
463 if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) -
464 data.entryFlags |= QFileSystemMetaData::BundleType; -
465 } -
466 -
467 data.knownFlagsMask |= QFileSystemMetaData::BundleType; -
468 } -
469#endif -
470 if (!entryExists) {
evaluated: !entryExists
TRUEFALSE
yes
Evaluation Count:8383
yes
Evaluation Count:38828
8383-38828
471 data.clearFlags(what);
executed (the execution status of this line is deduced): data.clearFlags(what);
-
472 return false;
executed: return false;
Execution Count:8382
8382
473 } -
474 return data.hasFlags(what);
executed: return data.hasFlags(what);
Execution Count:38828
38828
475} -
476 -
477//static -
478bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) -
479{ -
480 QString dirName = entry.filePath();
executed (the execution status of this line is deduced): QString dirName = entry.filePath();
-
481 if (createParents) {
evaluated: createParents
TRUEFALSE
yes
Evaluation Count:211
yes
Evaluation Count:1320
211-1320
482 dirName = QDir::cleanPath(dirName);
executed (the execution status of this line is deduced): dirName = QDir::cleanPath(dirName);
-
483 for (int oldslash = -1, slash=0; slash != -1; oldslash = slash) {
partially evaluated: slash != -1
TRUEFALSE
yes
Evaluation Count:1187
no
Evaluation Count:0
0-1187
484 slash = dirName.indexOf(QDir::separator(), oldslash+1);
executed (the execution status of this line is deduced): slash = dirName.indexOf(QDir::separator(), oldslash+1);
-
485 if (slash == -1) {
evaluated: slash == -1
TRUEFALSE
yes
Evaluation Count:422
yes
Evaluation Count:765
422-765
486 if (oldslash == dirName.length())
evaluated: oldslash == dirName.length()
TRUEFALSE
yes
Evaluation Count:211
yes
Evaluation Count:211
211
487 break;
executed: break;
Execution Count:211
211
488 slash = dirName.length();
executed (the execution status of this line is deduced): slash = dirName.length();
-
489 }
executed: }
Execution Count:211
211
490 if (slash) {
evaluated: slash
TRUEFALSE
yes
Evaluation Count:766
yes
Evaluation Count:210
210-766
491 const QByteArray chunk = QFile::encodeName(dirName.left(slash));
executed (the execution status of this line is deduced): const QByteArray chunk = QFile::encodeName(dirName.left(slash));
-
492 QT_STATBUF st;
executed (the execution status of this line is deduced): struct stat64 st;
-
493 if (QT_STAT(chunk.constData(), &st) != -1) {
evaluated: ::stat64(chunk.constData(), &st) != -1
TRUEFALSE
yes
Evaluation Count:508
yes
Evaluation Count:258
258-508
494 if ((st.st_mode & S_IFMT) != S_IFDIR)
partially evaluated: (st.st_mode & 0170000) != 0040000
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:508
0-508
495 return false;
never executed: return false;
0
496 } else if (QT_MKDIR(chunk.constData(), 0777) != 0) {
executed: }
Execution Count:508
partially evaluated: ::mkdir(chunk.constData(), 0777) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:258
0-508
497 return false;
never executed: return false;
0
498 } -
499 } -
500 }
executed: }
Execution Count:976
976
501 return true;
executed: return true;
Execution Count:211
211
502 } -
503#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s -
504 if (dirName.endsWith(QLatin1Char('/'))) -
505 dirName.chop(1); -
506#endif -
507 return (QT_MKDIR(QFile::encodeName(dirName).constData(), 0777) == 0);
executed: return (::mkdir(QFile::encodeName(dirName).constData(), 0777) == 0);
Execution Count:1320
1320
508} -
509 -
510//static -
511bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) -
512{ -
513 if (removeEmptyParents) {
evaluated: removeEmptyParents
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2372
4-2372
514 QString dirName = QDir::cleanPath(entry.filePath());
executed (the execution status of this line is deduced): QString dirName = QDir::cleanPath(entry.filePath());
-
515 for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
partially evaluated: slash > 0
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
516 const QByteArray chunk = QFile::encodeName(dirName.left(slash));
executed (the execution status of this line is deduced): const QByteArray chunk = QFile::encodeName(dirName.left(slash));
-
517 QT_STATBUF st;
executed (the execution status of this line is deduced): struct stat64 st;
-
518 if (QT_STAT(chunk.constData(), &st) != -1) {
evaluated: ::stat64(chunk.constData(), &st) != -1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
519 if ((st.st_mode & S_IFMT) != S_IFDIR)
partially evaluated: (st.st_mode & 0170000) != 0040000
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
520 return false;
never executed: return false;
0
521 if (::rmdir(chunk.constData()) != 0)
evaluated: ::rmdir(chunk.constData()) != 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
522 return oldslash != 0;
executed: return oldslash != 0;
Execution Count:1
1
523 } else {
executed: }
Execution Count:3
3
524 return false;
executed: return false;
Execution Count:3
3
525 } -
526 slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
executed (the execution status of this line is deduced): slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
-
527 }
executed: }
Execution Count:3
3
528 return true;
never executed: return true;
0
529 } -
530 return rmdir(QFile::encodeName(entry.filePath()).constData()) == 0;
executed: return rmdir(QFile::encodeName(entry.filePath()).constData()) == 0;
Execution Count:2372
2372
531} -
532 -
533//static -
534bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) -
535{ -
536 if (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0)
partially evaluated: ::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0
TRUEFALSE
yes
Evaluation Count:145
no
Evaluation Count:0
0-145
537 return true;
executed: return true;
Execution Count:145
145
538 error = QSystemError(errno, QSystemError::StandardLibraryError);
never executed (the execution status of this line is deduced): error = QSystemError((*__errno_location ()), QSystemError::StandardLibraryError);
-
539 return false;
never executed: return false;
0
540} -
541 -
542//static -
543bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) -
544{ -
545 Q_UNUSED(source);
executed (the execution status of this line is deduced): (void)source;;
-
546 Q_UNUSED(target);
executed (the execution status of this line is deduced): (void)target;;
-
547 error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented
executed (the execution status of this line is deduced): error = QSystemError(38, QSystemError::StandardLibraryError);
-
548 return false;
executed: return false;
Execution Count:96
96
549} -
550 -
551//static -
552bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) -
553{ -
554 if (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0)
evaluated: ::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0
TRUEFALSE
yes
Evaluation Count:199
yes
Evaluation Count:4
4-199
555 return true;
executed: return true;
Execution Count:199
199
556 error = QSystemError(errno, QSystemError::StandardLibraryError);
executed (the execution status of this line is deduced): error = QSystemError((*__errno_location ()), QSystemError::StandardLibraryError);
-
557 return false;
executed: return false;
Execution Count:4
4
558} -
559 -
560//static -
561bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error) -
562{ -
563 if (unlink(entry.nativeFilePath().constData()) == 0)
evaluated: unlink(entry.nativeFilePath().constData()) == 0
TRUEFALSE
yes
Evaluation Count:4879
yes
Evaluation Count:613
613-4879
564 return true;
executed: return true;
Execution Count:4879
4879
565 error = QSystemError(errno, QSystemError::StandardLibraryError);
executed (the execution status of this line is deduced): error = QSystemError((*__errno_location ()), QSystemError::StandardLibraryError);
-
566 return false;
executed: return false;
Execution Count:613
613
567 -
568} -
569 -
570//static -
571bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) -
572{ -
573 mode_t mode = 0;
executed (the execution status of this line is deduced): mode_t mode = 0;
-
574 if (permissions & QFile::ReadOwner)
evaluated: permissions & QFile::ReadOwner
TRUEFALSE
yes
Evaluation Count:494
yes
Evaluation Count:21
21-494
575 mode |= S_IRUSR;
executed: mode |= 0400;
Execution Count:494
494
576 if (permissions & QFile::WriteOwner)
evaluated: permissions & QFile::WriteOwner
TRUEFALSE
yes
Evaluation Count:442
yes
Evaluation Count:73
73-442
577 mode |= S_IWUSR;
executed: mode |= 0200;
Execution Count:442
442
578 if (permissions & QFile::ExeOwner)
evaluated: permissions & QFile::ExeOwner
TRUEFALSE
yes
Evaluation Count:220
yes
Evaluation Count:295
220-295
579 mode |= S_IXUSR;
executed: mode |= 0100;
Execution Count:220
220
580 if (permissions & QFile::ReadUser)
evaluated: permissions & QFile::ReadUser
TRUEFALSE
yes
Evaluation Count:476
yes
Evaluation Count:39
39-476
581 mode |= S_IRUSR;
executed: mode |= 0400;
Execution Count:476
476
582 if (permissions & QFile::WriteUser)
evaluated: permissions & QFile::WriteUser
TRUEFALSE
yes
Evaluation Count:427
yes
Evaluation Count:88
88-427
583 mode |= S_IWUSR;
executed: mode |= 0200;
Execution Count:427
427
584 if (permissions & QFile::ExeUser)
evaluated: permissions & QFile::ExeUser
TRUEFALSE
yes
Evaluation Count:220
yes
Evaluation Count:295
220-295
585 mode |= S_IXUSR;
executed: mode |= 0100;
Execution Count:220
220
586 if (permissions & QFile::ReadGroup)
evaluated: permissions & QFile::ReadGroup
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:301
214-301
587 mode |= S_IRGRP;
executed: mode |= (0400 >> 3);
Execution Count:214
214
588 if (permissions & QFile::WriteGroup)
partially evaluated: permissions & QFile::WriteGroup
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:515
0-515
589 mode |= S_IWGRP;
never executed: mode |= (0200 >> 3);
0
590 if (permissions & QFile::ExeGroup)
evaluated: permissions & QFile::ExeGroup
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:514
1-514
591 mode |= S_IXGRP;
executed: mode |= (0100 >> 3);
Execution Count:1
1
592 if (permissions & QFile::ReadOther)
evaluated: permissions & QFile::ReadOther
TRUEFALSE
yes
Evaluation Count:219
yes
Evaluation Count:296
219-296
593 mode |= S_IROTH;
executed: mode |= ((0400 >> 3) >> 3);
Execution Count:219
219
594 if (permissions & QFile::WriteOther)
evaluated: permissions & QFile::WriteOther
TRUEFALSE
yes
Evaluation Count:218
yes
Evaluation Count:297
218-297
595 mode |= S_IWOTH;
executed: mode |= ((0200 >> 3) >> 3);
Execution Count:218
218
596 if (permissions & QFile::ExeOther)
evaluated: permissions & QFile::ExeOther
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:513
2-513
597 mode |= S_IXOTH;
executed: mode |= ((0100 >> 3) >> 3);
Execution Count:2
2
598 -
599 bool success = ::chmod(entry.nativeFilePath().constData(), mode) == 0;
executed (the execution status of this line is deduced): bool success = ::chmod(entry.nativeFilePath().constData(), mode) == 0;
-
600 if (success && data) {
evaluated: success
TRUEFALSE
yes
Evaluation Count:510
yes
Evaluation Count:5
partially evaluated: data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:510
0-510
601 data->entryFlags &= ~QFileSystemMetaData::Permissions;
never executed (the execution status of this line is deduced): data->entryFlags &= ~QFileSystemMetaData::Permissions;
-
602 data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions));
never executed (the execution status of this line is deduced): data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions));
-
603 data->knownFlagsMask |= QFileSystemMetaData::Permissions;
never executed (the execution status of this line is deduced): data->knownFlagsMask |= QFileSystemMetaData::Permissions;
-
604 }
never executed: }
0
605 if (!success)
evaluated: !success
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:510
5-510
606 error = QSystemError(errno, QSystemError::StandardLibraryError);
executed: error = QSystemError((*__errno_location ()), QSystemError::StandardLibraryError);
Execution Count:5
5
607 return success;
executed: return success;
Execution Count:515
515
608} -
609 -
610QString QFileSystemEngine::homePath() -
611{ -
612 QString home = QFile::decodeName(qgetenv("HOME"));
executed (the execution status of this line is deduced): QString home = QFile::decodeName(qgetenv("HOME"));
-
613 if (home.isNull())
partially evaluated: home.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:732
0-732
614 home = rootPath();
never executed: home = rootPath();
0
615 return QDir::cleanPath(home);
executed: return QDir::cleanPath(home);
Execution Count:732
732
616} -
617 -
618QString QFileSystemEngine::rootPath() -
619{ -
620 return QLatin1String("/");
executed: return QLatin1String("/");
Execution Count:176
176
621} -
622 -
623QString QFileSystemEngine::tempPath() -
624{ -
625#ifdef QT_UNIX_TEMP_PATH_OVERRIDE -
626 return QLatin1String(QT_UNIX_TEMP_PATH_OVERRIDE); -
627#elif defined(Q_OS_BLACKBERRY) -
628 QString temp = QFile::decodeName(qgetenv("TEMP")); -
629 if (temp.isEmpty()) -
630 temp = QFile::decodeName(qgetenv("TMPDIR")); -
631 -
632 if (temp.isEmpty()) { -
633 qWarning("Neither the TEMP nor the TMPDIR environment variable is set, falling back to /tmp."); -
634 temp = QLatin1String("/tmp/"); -
635 } -
636 return QDir::cleanPath(temp); -
637#else -
638 QString temp = QFile::decodeName(qgetenv("TMPDIR"));
executed (the execution status of this line is deduced): QString temp = QFile::decodeName(qgetenv("TMPDIR"));
-
639 if (temp.isEmpty())
partially evaluated: temp.isEmpty()
TRUEFALSE
yes
Evaluation Count:2927
no
Evaluation Count:0
0-2927
640 temp = QLatin1String("/tmp/");
executed: temp = QLatin1String("/tmp/");
Execution Count:2927
2927
641 return QDir::cleanPath(temp);
executed: return QDir::cleanPath(temp);
Execution Count:2927
2927
642#endif -
643} -
644 -
645bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path) -
646{ -
647 int r;
executed (the execution status of this line is deduced): int r;
-
648 r = QT_CHDIR(path.nativeFilePath().constData());
executed (the execution status of this line is deduced): r = ::chdir(path.nativeFilePath().constData());
-
649 return r >= 0;
executed: return r >= 0;
Execution Count:296
296
650} -
651 -
652QFileSystemEntry QFileSystemEngine::currentPath() -
653{ -
654 QFileSystemEntry result;
executed (the execution status of this line is deduced): QFileSystemEntry result;
-
655 QT_STATBUF st;
executed (the execution status of this line is deduced): struct stat64 st;
-
656 if (QT_STAT(".", &st) == 0) {
partially evaluated: ::stat64(".", &st) == 0
TRUEFALSE
yes
Evaluation Count:1327
no
Evaluation Count:0
0-1327
657#if defined(__GLIBC__) && !defined(PATH_MAX) -
658 char *currentName = ::get_current_dir_name(); -
659 if (currentName) { -
660 result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath()); -
661 ::free(currentName); -
662 } -
663#else -
664 char currentName[PATH_MAX+1];
executed (the execution status of this line is deduced): char currentName[4096 +1];
-
665 if (::getcwd(currentName, PATH_MAX))
partially evaluated: ::getcwd(currentName, 4096)
TRUEFALSE
yes
Evaluation Count:1327
no
Evaluation Count:0
0-1327
666 result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
executed: result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
Execution Count:1327
1327
667# if defined(QT_DEBUG) -
668 if (result.isEmpty()) -
669 qWarning("QFileSystemEngine::currentPath: getcwd() failed"); -
670# endif -
671#endif -
672 } else {
executed: }
Execution Count:1327
1327
673# if defined(QT_DEBUG) -
674 qWarning("QFileSystemEngine::currentPath: stat(\".\") failed"); -
675# endif -
676 }
never executed: }
0
677 return result;
executed: return result;
Execution Count:1327
1327
678} -
679QT_END_NAMESPACE -
680 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial