io/qfilesystemengine_unix.cpp

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

Generated by Squish Coco Non-Commercial