Qt 4.8
qfilesystemengine_unix.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 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 "qplatformdefs.h"
45 #include "qfsfileengine.h"
46 #include "qfile.h"
47 
48 #include <QtCore/qvarlengtharray.h>
49 
50 #include <stdlib.h> // for realpath()
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 
61 
62 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
63 static 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
82 static inline bool _q_isMacHidden(const char *nativePath)
83 {
84  Q_UNUSED(nativePath);
85  // no-op
86  return false;
87 }
88 #endif
89 
91 {
92  return true;
93 }
94 
95 //static
97 {
98 #if defined(__GLIBC__) && !defined(PATH_MAX)
99 #define PATH_CHUNK_SIZE 256
100  char *s = 0;
101  int len = -1;
102  int size = PATH_CHUNK_SIZE;
103 
104  while (1) {
105  s = (char *) ::realloc(s, size);
106  Q_CHECK_PTR(s);
107  len = ::readlink(link.nativeFilePath().constData(), s, size);
108  if (len < 0) {
109  ::free(s);
110  break;
111  }
112  if (len < size) {
113  break;
114  }
115  size *= 2;
116  }
117 #else
118  char s[PATH_MAX+1];
119  int len = readlink(link.nativeFilePath().constData(), s, PATH_MAX);
120 #endif
121  if (len > 0) {
122  QString ret;
125  if (data.isDirectory() && s[0] != '/') {
126  QDir parent(link.filePath());
127  parent.cdUp();
128  ret = parent.path();
129  if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
130  ret += QLatin1Char('/');
131  }
132  s[len] = '\0';
133  ret += QFile::decodeName(QByteArray(s));
134 #if defined(__GLIBC__) && !defined(PATH_MAX)
135  ::free(s);
136 #endif
137 
138  if (!ret.startsWith(QLatin1Char('/'))) {
139  if (link.filePath().startsWith(QLatin1Char('/'))) {
140  ret.prepend(link.filePath().left(link.filePath().lastIndexOf(QLatin1Char('/')))
141  + QLatin1Char('/'));
142  } else {
143  ret.prepend(QDir::currentPath() + QLatin1Char('/'));
144  }
145  }
146  ret = QDir::cleanPath(ret);
147  if (ret.size() > 1 && ret.endsWith(QLatin1Char('/')))
148  ret.chop(1);
149  return QFileSystemEntry(ret);
150  }
151 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
152  {
153  FSRef fref;
154  if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) {
155  // TODO get the meta data info from the QFileSystemMetaData object
156  Boolean isAlias, isFolder;
157  if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) {
158  AliasHandle alias;
159  if (FSNewAlias(0, &fref, &alias) == noErr && alias) {
160  QCFString cfstr;
161  if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr)
162  return QFileSystemEntry(QCFString::toQString(cfstr));
163  }
164  }
165  }
166  }
167 #endif
168  return QFileSystemEntry();
169 }
170 
171 //static
173 {
174  if (entry.isEmpty() || entry.isRoot())
175  return entry;
176 
177 #if !defined(Q_OS_MAC) && !defined(Q_OS_QNX) && _POSIX_VERSION < 200809L
178  // realpath(X,0) is not supported
179  Q_UNUSED(data);
180  return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
181 #else
182  char *ret = 0;
183 # if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
184  // When using -mmacosx-version-min=10.4, we get the legacy realpath implementation,
185  // which does not work properly with the realpath(X,0) form. See QTBUG-28282.
187  ret = (char*)malloc(PATH_MAX + 1);
188  if (ret && realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
189  const int savedErrno = errno; // errno is checked below, and free() might change it
190  free(ret);
191  errno = savedErrno;
192  ret = 0;
193  }
194  } else {
195  // on 10.5 we can use FSRef to resolve the file path.
196  QString path = QDir::cleanPath(entry.filePath());
197  FSRef fsref;
198  if (FSPathMakeRef((const UInt8 *)path.toUtf8().data(), &fsref, 0) == noErr) {
199  CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref);
200  CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle);
201  QString ret = QCFString::toQString(canonicalPath);
202  CFRelease(canonicalPath);
203  CFRelease(urlref);
204  return QFileSystemEntry(ret);
205  }
206  }
207 # else
208 # if _POSIX_VERSION >= 200801L
209  ret = realpath(entry.nativeFilePath().constData(), (char*)0);
210 # else
211  ret = (char*)malloc(PATH_MAX + 1);
212  if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
213  const int savedErrno = errno; // errno is checked below, and free() might change it
214  free(ret);
215  errno = savedErrno;
216  ret = 0;
217  }
218 # endif
219 # endif
220  if (ret) {
223  QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
224  free(ret);
225  return QFileSystemEntry(canonicalPath);
226  } else if (errno == ENOENT) { // file doesn't exist
229  return QFileSystemEntry();
230  }
231  return entry;
232 #endif
233 }
234 
235 //static
237 {
238  if (entry.isAbsolute() && entry.isClean())
239  return entry;
240 
241  QByteArray orig = entry.nativeFilePath();
242  QByteArray result;
243  if (orig.isEmpty() || !orig.startsWith('/')) {
245  result = cur.nativeFilePath();
246  }
247  if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) {
248  if (!result.isEmpty() && !result.endsWith('/'))
249  result.append('/');
250  result.append(orig);
251  }
252 
253  if (result.length() == 1 && result[0] == '/')
255  const bool isDir = result.endsWith('/');
256 
257  /* as long as QDir::cleanPath() operates on a QString we have to convert to a string here.
258  * ideally we never convert to a string since that loses information. Please fix after
259  * we get a QByteArray version of QDir::cleanPath()
260  */
261  QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath());
262  QString stringVersion = QDir::cleanPath(resultingEntry.filePath());
263  if (isDir)
264  stringVersion.append(QLatin1Char('/'));
265  return QFileSystemEntry(stringVersion);
266 }
267 
268 //static
270 {
271 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
272  int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
273  if (size_max == -1)
274  size_max = 1024;
275  QVarLengthArray<char, 1024> buf(size_max);
276 #endif
277 
278  struct passwd *pw = 0;
279 #if !defined(Q_OS_INTEGRITY)
280 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS)
281  struct passwd entry;
282  getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw);
283 #else
284  pw = getpwuid(userId);
285 #endif
286 #endif
287  if (pw)
288  return QFile::decodeName(QByteArray(pw->pw_name));
289  return QString();
290 }
291 
292 //static
294 {
295 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
296  int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
297  if (size_max == -1)
298  size_max = 1024;
299  QVarLengthArray<char, 1024> buf(size_max);
300 #endif
301 
302  struct group *gr = 0;
303 #if !defined(Q_OS_INTEGRITY)
304 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS)
305  size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
306  if (size_max == -1)
307  size_max = 1024;
308  buf.resize(size_max);
309  struct group entry;
310  // Some large systems have more members than the POSIX max size
311  // Loop over by doubling the buffer size (upper limit 250k)
312  for (unsigned size = size_max; size < 256000; size += size)
313  {
314  buf.resize(size);
315  // ERANGE indicates that the buffer was too small
316  if (!getgrgid_r(groupId, &entry, buf.data(), buf.size(), &gr)
317  || errno != ERANGE)
318  break;
319  }
320 #else
321  gr = getgrgid(groupId);
322 #endif
323 #endif
324  if (gr)
325  return QFile::decodeName(QByteArray(gr->gr_name));
326  return QString();
327 }
328 
329 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
330 //static
332 {
333  QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(entry.filePath()),
334  kCFURLPOSIXPathStyle, true);
335  if (QCFType<CFDictionaryRef> dict = CFBundleCopyInfoDictionaryForURL(url)) {
336  if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) {
337  if (CFGetTypeID(name) == CFStringGetTypeID())
339  }
340  }
341  return QString();
342 }
343 #endif
344 
345 //static
347  QFileSystemMetaData::MetaDataFlags what)
348 {
349 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
350  if (what & QFileSystemMetaData::BundleType) {
353  }
354 #endif
355 
356 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) \
357  && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
359  // Mac OS >= 10.5: st_flags & UF_HIDDEN
361  }
362 #endif
363 
366 
368  // FIXME: Would other queries being performed provide this bit?
370  }
371 
372  data.entryFlags &= ~what;
373 
374  const char * nativeFilePath;
375  int nativeFilePathLength;
376  {
377  const QByteArray &path = entry.nativeFilePath();
378  nativeFilePath = path.constData();
379  nativeFilePathLength = path.size();
380  Q_UNUSED(nativeFilePathLength);
381  }
382 
383  bool entryExists = true; // innocent until proven otherwise
384 
385  QT_STATBUF statBuffer;
386  bool statBufferValid = false;
387  if (what & QFileSystemMetaData::LinkType) {
388  if (QT_LSTAT(nativeFilePath, &statBuffer) == 0) {
389  if (S_ISLNK(statBuffer.st_mode)) {
391  } else {
392  statBufferValid = true;
393  data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags;
394  }
395  } else {
396  entryExists = false;
397  }
398 
400  }
401 
402  if (statBufferValid || (what & QFileSystemMetaData::PosixStatFlags)) {
403  if (entryExists && !statBufferValid)
404  statBufferValid = (QT_STAT(nativeFilePath, &statBuffer) == 0);
405 
406  if (statBufferValid)
407  data.fillFromStatBuf(statBuffer);
408  else {
409  entryExists = false;
410  data.creationTime_ = 0;
411  data.modificationTime_ = 0;
412  data.accessTime_ = 0;
413  data.size_ = 0;
414  data.userId_ = (uint) -2;
415  data.groupId_ = (uint) -2;
416  }
417 
418  // reset the mask
419  data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags
421  }
422 
423 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
425  {
426  if (entryExists) {
427  FSRef fref;
428  if (FSPathMakeRef((const UInt8 *)nativeFilePath, &fref, NULL) == noErr) {
429  Boolean isAlias, isFolder;
430  if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr) {
431  if (isAlias)
433  }
434  }
435  }
437  }
438 #endif
439 
441  // calculate user permissions
442 
443  if (entryExists) {
445  if (QT_ACCESS(nativeFilePath, R_OK) == 0)
446  data.entryFlags |= QFileSystemMetaData::UserReadPermission;
447  }
449  if (QT_ACCESS(nativeFilePath, W_OK) == 0)
450  data.entryFlags |= QFileSystemMetaData::UserWritePermission;
451  }
453  if (QT_ACCESS(nativeFilePath, X_OK) == 0)
454  data.entryFlags |= QFileSystemMetaData::UserExecutePermission;
455  }
456  }
458  }
459 
460  if (what & QFileSystemMetaData::HiddenAttribute
461  && !data.isHidden()) {
462  QString fileName = entry.fileName();
463  if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.'))
464  || (entryExists && _q_isMacHidden(nativeFilePath)))
467  }
468 
469 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
470  if (what & QFileSystemMetaData::BundleType) {
471  if (entryExists && data.isDirectory()) {
472  QCFType<CFStringRef> path = CFStringCreateWithBytes(0,
473  (const UInt8*)nativeFilePath, nativeFilePathLength,
474  kCFStringEncodingUTF8, false);
475  QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path,
476  kCFURLPOSIXPathStyle, true);
477 
478  UInt32 type, creator;
479  if (CFBundleGetPackageInfoInDirectory(url, &type, &creator))
481  }
482 
484  }
485 #endif
486 
487  return data.hasFlags(what);
488 }
489 
490 //static
491 bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents)
492 {
493  QString dirName = entry.filePath();
494  if (createParents) {
495  dirName = QDir::cleanPath(dirName);
496  for (int oldslash = -1, slash=0; slash != -1; oldslash = slash) {
497  slash = dirName.indexOf(QDir::separator(), oldslash+1);
498  if (slash == -1) {
499  if (oldslash == dirName.length())
500  break;
501  slash = dirName.length();
502  }
503  if (slash) {
504  QByteArray chunk = QFile::encodeName(dirName.left(slash));
505  QT_STATBUF st;
506  if (QT_STAT(chunk, &st) != -1) {
507  if ((st.st_mode & S_IFMT) != S_IFDIR)
508  return false;
509  } else if (QT_MKDIR(chunk, 0777) != 0) {
510  return false;
511  }
512  }
513  }
514  return true;
515  }
516 #if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s
517  if (dirName.endsWith(QLatin1Char('/')))
518  dirName.chop(1);
519 #endif
520  return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0);
521 }
522 
523 //static
524 bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
525 {
526  if (removeEmptyParents) {
527  QString dirName = QDir::cleanPath(entry.filePath());
528  for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
529  QByteArray chunk = QFile::encodeName(dirName.left(slash));
530  QT_STATBUF st;
531  if (QT_STAT(chunk, &st) != -1) {
532  if ((st.st_mode & S_IFMT) != S_IFDIR)
533  return false;
534  if (::rmdir(chunk) != 0)
535  return oldslash != 0;
536  } else {
537  return false;
538  }
539  slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
540  }
541  return true;
542  }
543  return rmdir(QFile::encodeName(entry.filePath())) == 0;
544 }
545 
546 //static
548 {
549  if (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0)
550  return true;
552  return false;
553 }
554 
555 //static
557 {
558  Q_UNUSED(source);
559  Q_UNUSED(target);
560  error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented
561  return false;
562 }
563 
564 //static
566 {
567  if (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0)
568  return true;
570  return false;
571 }
572 
573 //static
575 {
576  if (unlink(entry.nativeFilePath().constData()) == 0)
577  return true;
579  return false;
580 
581 }
582 
583 //static
584 bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
585 {
586  mode_t mode = 0;
587  if (permissions & QFile::ReadOwner)
588  mode |= S_IRUSR;
589  if (permissions & QFile::WriteOwner)
590  mode |= S_IWUSR;
591  if (permissions & QFile::ExeOwner)
592  mode |= S_IXUSR;
593  if (permissions & QFile::ReadUser)
594  mode |= S_IRUSR;
595  if (permissions & QFile::WriteUser)
596  mode |= S_IWUSR;
597  if (permissions & QFile::ExeUser)
598  mode |= S_IXUSR;
599  if (permissions & QFile::ReadGroup)
600  mode |= S_IRGRP;
601  if (permissions & QFile::WriteGroup)
602  mode |= S_IWGRP;
603  if (permissions & QFile::ExeGroup)
604  mode |= S_IXGRP;
605  if (permissions & QFile::ReadOther)
606  mode |= S_IROTH;
607  if (permissions & QFile::WriteOther)
608  mode |= S_IWOTH;
609  if (permissions & QFile::ExeOther)
610  mode |= S_IXOTH;
611 
612  bool success = ::chmod(entry.nativeFilePath().constData(), mode) == 0;
613  if (success && data) {
614  data->entryFlags &= ~QFileSystemMetaData::Permissions;
615  data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions));
617  }
618  if (!success)
620  return success;
621 }
622 
624 {
625  QString home = QFile::decodeName(qgetenv("HOME"));
626  if (home.isEmpty())
627  home = rootPath();
628  return QDir::cleanPath(home);
629 }
630 
632 {
633  return QLatin1String("/");
634 }
635 
637 {
638 #ifdef QT_UNIX_TEMP_PATH_OVERRIDE
639  return QLatin1String(QT_UNIX_TEMP_PATH_OVERRIDE);
640 #elif defined(Q_OS_BLACKBERRY)
641  QString temp = QFile::decodeName(qgetenv("TEMP"));
642  if (temp.isEmpty())
643  temp = QFile::decodeName(qgetenv("TMPDIR"));
644 
645  if (temp.isEmpty()) {
646  qWarning("Neither the TEMP nor the TMPDIR environment variable is set, falling back to /tmp.");
647  temp = QLatin1String("/tmp/");
648  }
649  return QDir::cleanPath(temp);
650 #else
651  QString temp = QFile::decodeName(qgetenv("TMPDIR"));
652  if (temp.isEmpty())
653  temp = QLatin1String("/tmp/");
654  return QDir::cleanPath(temp);
655 #endif
656 }
657 
659 {
660  int r;
661  r = QT_CHDIR(path.nativeFilePath());
662  return r >= 0;
663 }
664 
666 {
667  QFileSystemEntry result;
668  QT_STATBUF st;
669  if (QT_STAT(".", &st) == 0) {
670 #if defined(__GLIBC__) && !defined(PATH_MAX)
671  char *currentName = ::get_current_dir_name();
672  if (currentName) {
674  ::free(currentName);
675  }
676 #else
677  char currentName[PATH_MAX+1];
678  if (::getcwd(currentName, PATH_MAX)) {
679 #if defined(Q_OS_VXWORKS) && defined(VXWORKS_VXSIM)
680  QByteArray dir(currentName);
681  if (dir.indexOf(':') < dir.indexOf('/'))
682  dir.remove(0, dir.indexOf(':')+1);
683 
684  qstrncpy(currentName, dir.constData(), PATH_MAX);
685 #endif
687  }
688 # if defined(QT_DEBUG)
689  if (result.isEmpty())
690  qWarning("QFSFileEngine::currentPath: getcwd() failed");
691 # endif
692 #endif
693  } else {
694 # if defined(QT_DEBUG)
695  qWarning("QFSFileEngine::currentPath: stat(\".\") failed");
696 # endif
697  }
698  return result;
699 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
#define S_IWOTH
Definition: qzip.cpp:83
void resize(int size)
const struct __CFString * CFStringRef
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data=0)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int type
Definition: qmetatype.cpp:239
#define S_IRGRP
Definition: qzip.cpp:79
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define S_IXGRP
Definition: qzip.cpp:81
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QByteArray & append(char c)
Appends the character ch to this byte array.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
#define S_IRUSR
Definition: qzip.cpp:71
QString & prepend(QChar c)
Definition: qstring.h:261
#define S_IXUSR
Definition: qzip.cpp:77
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isAbsolute() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
Definition: qdir.cpp:1831
#define S_IFMT
static QFileSystemEntry currentPath()
NativePath nativeFilePath() const
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
Definition: qfile.cpp:552
int mode_t
bool cdUp()
Changes directory by moving one directory up from the QDir&#39;s current directory.
Definition: qdir.cpp:937
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QFileSystemEntry absoluteName(const QFileSystemEntry &entry)
static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define S_IXOTH
Definition: qzip.cpp:84
static QString slowCanonicalized(const QString &path)
Returns the canonicalized form of path (i.
const char * name
QString fileName() const
Q_CORE_EXPORT void qWarning(const char *,...)
#define S_IROTH
Definition: qzip.cpp:82
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
bool hasFlags(MetaDataFlags flags) const
static QString cleanPath(const QString &path)
Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path...
Definition: qdir.cpp:2082
static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data)
#define PATH_MAX
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
const void * CFTypeRef
static bool createDirectory(const QFileSystemEntry &entry, bool createParents)
static QString bundleName(const QFileSystemEntry &entry)
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static bool _q_isMacHidden(const char *nativePath)
static bool setCurrentPath(const QFileSystemEntry &entry)
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
QString & append(QChar c)
Definition: qstring.cpp:1777
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static bool removeFile(const QFileSystemEntry &entry, QSystemError &error)
#define S_IFDIR
#define st(var, type, card)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
QString filePath() const
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528
static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
#define S_IWGRP
Definition: qzip.cpp:80
#define S_ISLNK(x)
Definition: qzip.cpp:69
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static QString fileName(const QString &fileUrl)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712
Q_CORE_EXPORT char * qstrncpy(char *dst, const char *src, uint len)
QByteArray & remove(int index, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the arra...
int size() const
int errno
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
#define S_IWUSR
Definition: qzip.cpp:74
static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
void fillFromStatBuf(const QT_STATBUF &statBuffer)