Qt 4.8
qfileinfo.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 "qfileinfo.h"
44 #include "qglobal.h"
45 #include "qdir.h"
46 #include "qfileinfo_p.h"
47 
49 
51 {
52  if (cache_enabled && !fileNames[(int)name].isNull())
53  return fileNames[(int)name];
54 
55  QString ret;
56  if (fileEngine == 0) { // local file; use the QFileSystemEngine directly
57  switch (name) {
61  if (cache_enabled) { // be smart and store both
64  }
66  ret = entry.filePath();
67  else
68  ret = entry.path();
69  break;
70  }
73  break;
76  break;
80  if (cache_enabled) { // be smart and store both
83  }
85  ret = entry.filePath();
86  else
87  ret = entry.path();
88  break;
89  }
90  default: break;
91  }
92  } else {
93  ret = fileEngine->fileName(name);
94  }
95  if (ret.isNull())
96  ret = QLatin1String("");
97  if (cache_enabled)
98  fileNames[(int)name] = ret;
99  return ret;
100 }
101 
103 {
104  if (cache_enabled && !fileOwners[(int)own].isNull())
105  return fileOwners[(int)own];
106  QString ret;
107  if (fileEngine == 0) {
108  switch (own) {
111  break;
114  break;
115  }
116  } else {
117  ret = fileEngine->owner(own);
118  }
119  if (ret.isNull())
120  ret = QLatin1String("");
121  if (cache_enabled)
122  fileOwners[(int)own] = ret;
123  return ret;
124 }
125 
126 uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const
127 {
128  Q_ASSERT(fileEngine); // should never be called when using the native FS
129  // We split the testing into tests for for LinkType, BundleType, PermsMask
130  // and the rest.
131  // Tests for file permissions on Windows can be slow, expecially on network
132  // paths and NTFS drives.
133  // In order to determine if a file is a symlink or not, we have to lstat().
134  // If we're not interested in that information, we might as well avoid one
135  // extra syscall. Bundle detecton on Mac can be slow, expecially on network
136  // paths, so we separate out that as well.
137 
138  QAbstractFileEngine::FileFlags req = 0;
139  uint cachedFlags = 0;
140 
145  req &= (~QAbstractFileEngine::LinkType);
146  req &= (~QAbstractFileEngine::BundleType);
147 
148  cachedFlags |= CachedFileFlags;
149  }
150 
151  if (request & QAbstractFileEngine::LinkType) {
154  cachedFlags |= CachedLinkTypeFlag;
155  }
156  }
157 
158  if (request & QAbstractFileEngine::BundleType) {
161  cachedFlags |= CachedBundleTypeFlag;
162  }
163  }
164  }
165 
166  if (request & QAbstractFileEngine::PermsMask) {
167  if (!getCachedFlag(CachedPerms)) {
169  cachedFlags |= CachedPerms;
170  }
171  }
172 
173  if (req) {
174  if (cache_enabled)
175  req &= (~QAbstractFileEngine::Refresh);
176  else
178 
179  QAbstractFileEngine::FileFlags flags = fileEngine->fileFlags(req);
180  fileFlags |= uint(flags);
181  setCachedFlag(cachedFlags);
182  }
183 
184  return fileFlags & request;
185 }
186 
188 {
189  Q_ASSERT(fileEngine); // should never be called when using the native FS
190  if (!cache_enabled)
191  clearFlags();
192  uint cf;
193  if (request == QAbstractFileEngine::CreationTime)
194  cf = CachedCTime;
195  else if (request == QAbstractFileEngine::ModificationTime)
196  cf = CachedMTime;
197  else
198  cf = CachedATime;
199  if (!getCachedFlag(cf)) {
200  fileTimes[request] = fileEngine->fileTime(request);
201  setCachedFlag(cf);
202  }
203  return fileTimes[request];
204 }
205 
206 //************* QFileInfo
207 
300 {
301 }
302 
311 {
312 }
313 
321 {
322 }
323 
334 {
335 }
336 
349 QFileInfo::QFileInfo(const QDir &dir, const QString &file)
350  : d_ptr(new QFileInfoPrivate(dir.filePath(file)))
351 {
352 }
353 
358  : d_ptr(fileinfo.d_ptr)
359 {
360 
361 }
362 
368 {
369 }
370 
391 bool QFileInfo::operator==(const QFileInfo &fileinfo) const
392 {
393  Q_D(const QFileInfo);
394  // ### Qt 5: understand long and short file names on Windows
395  // ### (GetFullPathName()).
396  if (fileinfo.d_ptr == d_ptr)
397  return true;
398  if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
399  return false;
400 
401  // Assume files are the same if path is the same
402  if (d->fileEntry.filePath() == fileinfo.d_ptr->fileEntry.filePath())
403  return true;
404 
405  Qt::CaseSensitivity sensitive;
406  if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) {
407  if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine
408  return false;
409 
411  } else {
412  if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
413  return false;
414  sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
415  }
416 
417  if (fileinfo.size() != size()) //if the size isn't the same...
418  return false;
419 
420  // Fallback to expensive canonical path computation
421  return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
422 }
423 
439 bool QFileInfo::operator==(const QFileInfo &fileinfo)
440 {
441  return const_cast<const QFileInfo *>(this)->operator==(fileinfo);
442 }
443 
448 {
449  d_ptr = fileinfo.d_ptr;
450  return *this;
451 }
452 
468 void QFileInfo::setFile(const QString &file)
469 {
471  *this = QFileInfo(file);
473 }
474 
489 void QFileInfo::setFile(const QFile &file)
490 {
491  setFile(file.fileName());
492 }
493 
508 void QFileInfo::setFile(const QDir &dir, const QString &file)
509 {
510  setFile(dir.filePath(file));
511 }
512 
535 {
536  Q_D(const QFileInfo);
537  if (d->isDefaultConstructed)
538  return QLatin1String("");
539  return d->getFileName(QAbstractFileEngine::AbsoluteName);
540 }
541 
552 {
553  Q_D(const QFileInfo);
554  if (d->isDefaultConstructed)
555  return QLatin1String("");
556  return d->getFileName(QAbstractFileEngine::CanonicalName);
557 }
558 
559 
578 {
579  Q_D(const QFileInfo);
580 
581  if (d->isDefaultConstructed) {
582  return QLatin1String("");
583  } else if (d->fileEntry.isEmpty()) {
584  qWarning("QFileInfo::absolutePath: Constructed with empty filename");
585  return QLatin1String("");
586  }
587  return d->getFileName(QAbstractFileEngine::AbsolutePathName);
588 }
589 
599 {
600  Q_D(const QFileInfo);
601  if (d->isDefaultConstructed)
602  return QLatin1String("");
603  return d->getFileName(QAbstractFileEngine::CanonicalPathName);
604 }
605 
616 {
617  Q_D(const QFileInfo);
618  if (d->isDefaultConstructed)
619  return QLatin1String("");
620  return d->fileEntry.path();
621 }
622 
643 {
644  Q_D(const QFileInfo);
645  if (d->isDefaultConstructed)
646  return true;
647  if (d->fileEngine == 0)
648  return d->fileEntry.isRelative();
649  return d->fileEngine->isRelativePath();
650 }
651 
660 {
663  return false;
664 
666  return true;
667 }
668 
675 bool QFileInfo::exists() const
676 {
677  Q_D(const QFileInfo);
678  if (d->isDefaultConstructed)
679  return false;
680  if (d->fileEngine == 0) {
681  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute))
683  return d->metaData.exists();
684  }
685  return d->getFileFlags(QAbstractFileEngine::ExistsFlag);
686 }
687 
696 {
697  Q_D(QFileInfo);
698  d->clear();
699 }
700 
708 {
709  Q_D(const QFileInfo);
710  if (d->isDefaultConstructed)
711  return QLatin1String("");
712  return d->fileEntry.filePath();
713 }
714 
727 {
728  Q_D(const QFileInfo);
729  if (d->isDefaultConstructed)
730  return QLatin1String("");
731  return d->fileEntry.fileName();
732 }
733 
750 {
751  Q_D(const QFileInfo);
752  if (d->isDefaultConstructed)
753  return QLatin1String("");
754  return d->getFileName(QAbstractFileEngine::BundleName);
755 }
756 
774 {
775  Q_D(const QFileInfo);
776  if (d->isDefaultConstructed)
777  return QLatin1String("");
778  return d->fileEntry.baseName();
779 }
780 
793 {
794  Q_D(const QFileInfo);
795  if (d->isDefaultConstructed)
796  return QLatin1String("");
797  return d->fileEntry.completeBaseName();
798 }
799 
812 {
813  Q_D(const QFileInfo);
814  if (d->isDefaultConstructed)
815  return QLatin1String("");
816  return d->fileEntry.completeSuffix();
817 }
818 
835 {
836  Q_D(const QFileInfo);
837  if (d->isDefaultConstructed)
838  return QLatin1String("");
839  return d->fileEntry.suffix();
840 }
841 
842 
862 {
863  Q_D(const QFileInfo);
864  // ### Qt5: Maybe rename this to parentDirectory(), considering what it actually do?
865  return QDir(d->fileEntry.path());
866 }
867 
874 {
875  return QDir(absolutePath());
876 }
877 
878 #ifdef QT3_SUPPORT
879 
883 QDir QFileInfo::dir(bool absPath) const
884 {
885  if (absPath)
886  return absoluteDir();
887  return dir();
888 }
889 #endif //QT3_SUPPORT
890 
897 {
898  Q_D(const QFileInfo);
899  if (d->isDefaultConstructed)
900  return false;
901  if (d->fileEngine == 0) {
902  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission))
904  return (d->metaData.permissions() & QFile::ReadUser) != 0;
905  }
906  return d->getFileFlags(QAbstractFileEngine::ReadUserPerm);
907 }
908 
915 {
916  Q_D(const QFileInfo);
917  if (d->isDefaultConstructed)
918  return false;
919  if (d->fileEngine == 0) {
920  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserWritePermission))
922  return (d->metaData.permissions() & QFile::WriteUser) != 0;
923  }
924  return d->getFileFlags(QAbstractFileEngine::WriteUserPerm);
925 }
926 
933 {
934  Q_D(const QFileInfo);
935  if (d->isDefaultConstructed)
936  return false;
937  if (d->fileEngine == 0) {
938  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserExecutePermission))
940  return (d->metaData.permissions() & QFile::ExeUser) != 0;
941  }
942  return d->getFileFlags(QAbstractFileEngine::ExeUserPerm);
943 }
944 
952 {
953  Q_D(const QFileInfo);
954  if (d->isDefaultConstructed)
955  return false;
956  if (d->fileEngine == 0) {
957  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::HiddenAttribute))
959  return d->metaData.isHidden();
960  }
961  return d->getFileFlags(QAbstractFileEngine::HiddenFlag);
962 }
963 
971 bool QFileInfo::isFile() const
972 {
973  Q_D(const QFileInfo);
974  if (d->isDefaultConstructed)
975  return false;
976  if (d->fileEngine == 0) {
977  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::FileType))
979  return d->metaData.isFile();
980  }
981  return d->getFileFlags(QAbstractFileEngine::FileType);
982 }
983 
990 bool QFileInfo::isDir() const
991 {
992  Q_D(const QFileInfo);
993  if (d->isDefaultConstructed)
994  return false;
995  if (d->fileEngine == 0) {
996  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::DirectoryType))
998  return d->metaData.isDirectory();
999  }
1000  return d->getFileFlags(QAbstractFileEngine::DirectoryType);
1001 }
1002 
1003 
1015 {
1016  Q_D(const QFileInfo);
1017  if (d->isDefaultConstructed)
1018  return false;
1019  if (d->fileEngine == 0) {
1020  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::BundleType))
1022  return d->metaData.isBundle();
1023  }
1024  return d->getFileFlags(QAbstractFileEngine::BundleType);
1025 }
1026 
1045 {
1046  Q_D(const QFileInfo);
1047  if (d->isDefaultConstructed)
1048  return false;
1049  if (d->fileEngine == 0) {
1050  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::LegacyLinkType))
1052  return d->metaData.isLegacyLink();
1053  }
1054  return d->getFileFlags(QAbstractFileEngine::LinkType);
1055 }
1056 
1062 bool QFileInfo::isRoot() const
1063 {
1064  Q_D(const QFileInfo);
1065  if (d->isDefaultConstructed)
1066  return true;
1067  if (d->fileEngine == 0) {
1068  if (d->fileEntry.isRoot()) {
1069 #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
1070  //the path is a drive root, but the drive may not exist
1071  //for backward compatibility, return true only if the drive exists
1072  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute))
1074  return d->metaData.exists();
1075 #else
1076  return true;
1077 #endif
1078  }
1079  return false;
1080  }
1081  return d->getFileFlags(QAbstractFileEngine::RootFlag);
1082 }
1083 
1111 {
1112  Q_D(const QFileInfo);
1113  if (d->isDefaultConstructed)
1114  return QLatin1String("");
1115  return d->getFileName(QAbstractFileEngine::LinkName);
1116 }
1117 
1129 {
1130  Q_D(const QFileInfo);
1131  if (d->isDefaultConstructed)
1132  return QLatin1String("");
1133  return d->getFileOwner(QAbstractFileEngine::OwnerUser);
1134 }
1135 
1145 {
1146  Q_D(const QFileInfo);
1147  if (d->isDefaultConstructed)
1148  return 0;
1149  if (d->fileEngine == 0) {
1150  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserId))
1152  return d->metaData.userId();
1153  }
1154  return d->fileEngine->ownerId(QAbstractFileEngine::OwnerUser);
1155 }
1156 
1168 {
1169  Q_D(const QFileInfo);
1170  if (d->isDefaultConstructed)
1171  return QLatin1String("");
1172  return d->getFileOwner(QAbstractFileEngine::OwnerGroup);
1173 }
1174 
1184 {
1185  Q_D(const QFileInfo);
1186  if (d->isDefaultConstructed)
1187  return 0;
1188  if (d->fileEngine == 0) {
1189  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::GroupId))
1191  return d->metaData.groupId();
1192  }
1193  return d->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup);
1194 }
1195 
1209 bool QFileInfo::permission(QFile::Permissions permissions) const
1210 {
1211  Q_D(const QFileInfo);
1212  if (d->isDefaultConstructed)
1213  return false;
1214  if (d->fileEngine == 0) {
1215  // the QFileSystemMetaData::MetaDataFlag and QFile::Permissions overlap, so just static cast.
1216  QFileSystemMetaData::MetaDataFlag permissionFlags = static_cast<QFileSystemMetaData::MetaDataFlag>((int)permissions);
1217  if (!d->cache_enabled || !d->metaData.hasFlags(permissionFlags))
1218  QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, permissionFlags);
1219  return (d->metaData.permissions() & permissions) == permissions;
1220  }
1221  return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions;
1222 }
1223 
1228 QFile::Permissions QFileInfo::permissions() const
1229 {
1230  Q_D(const QFileInfo);
1231  if (d->isDefaultConstructed)
1232  return 0;
1233  if (d->fileEngine == 0) {
1234  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::Permissions))
1236  return d->metaData.permissions();
1237  }
1238  return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask);
1239 }
1240 
1241 
1249 {
1250  Q_D(const QFileInfo);
1251  if (d->isDefaultConstructed)
1252  return 0;
1253  if (d->fileEngine == 0) {
1254  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::SizeAttribute))
1256  return d->metaData.size();
1257  }
1258  if (!d->getCachedFlag(QFileInfoPrivate::CachedSize)) {
1259  d->setCachedFlag(QFileInfoPrivate::CachedSize);
1260  d->fileSize = d->fileEngine->size();
1261  }
1262  return d->fileSize;
1263 }
1264 
1279 {
1280  Q_D(const QFileInfo);
1281  if (d->isDefaultConstructed)
1282  return QDateTime();
1283  if (d->fileEngine == 0) {
1284  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::CreationTime))
1286  return d->metaData.creationTime();
1287  }
1288  return d->getFileTime(QAbstractFileEngine::CreationTime);
1289 }
1290 
1297 {
1298  Q_D(const QFileInfo);
1299  if (d->isDefaultConstructed)
1300  return QDateTime();
1301  if (d->fileEngine == 0) {
1302  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ModificationTime))
1304  return d->metaData.modificationTime();
1305  }
1306  return d->getFileTime(QAbstractFileEngine::ModificationTime);
1307 }
1308 
1318 {
1319  Q_D(const QFileInfo);
1320  if (d->isDefaultConstructed)
1321  return QDateTime();
1322  if (d->fileEngine == 0) {
1323  if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::AccessTime))
1325  return d->metaData.accessTime();
1326  }
1327  return d->getFileTime(QAbstractFileEngine::AccessTime);
1328 }
1329 
1337 {
1338  d_ptr.detach();
1339 }
1340 
1347 {
1348  Q_D(const QFileInfo);
1349  return d->cache_enabled;
1350 }
1351 
1364 void QFileInfo::setCaching(bool enable)
1365 {
1366  Q_D(QFileInfo);
1367  d->cache_enabled = enable;
1368 }
1369 
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)
double d
Definition: qnumeric_p.h:62
virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const
This function should return the set of OR&#39;d flags that are true for the file engine&#39;s file...
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
Definition: qfile.cpp:470
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QDateTime lastRead() const
Returns the date and time when the file was last read (accessed).
Definition: qfileinfo.cpp:1317
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
bool isHidden() const
Returns true if this is a `hidden&#39; file; otherwise returns false.
Definition: qfileinfo.cpp:951
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void clearFlags() const
Definition: qfileinfo_p.h:122
QDir dir() const
Returns the path of the object&#39;s parent directory as a QDir object.
Definition: qfileinfo.cpp:861
virtual QString fileName(FileName file=DefaultName) const
Return the file engine&#39;s current file name in the format specified by file.
void refresh()
Refreshes the information about the file, i.e.
Definition: qfileinfo.cpp:695
QFileInfo & operator=(const QFileInfo &fileinfo)
Makes a copy of the given fileinfo and assigns it to this QFileInfo.
Definition: qfileinfo.cpp:447
bool getCachedFlag(uint c) const
Definition: qfileinfo_p.h:156
QDateTime created() const
Returns the date and time when the file was created.
Definition: qfileinfo.cpp:1278
void detach()
If the shared data object&#39;s reference count is greater than 1, this function creates a deep copy of t...
Definition: qshareddata.h:75
static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
QDir absoluteDir() const
Returns the file&#39;s absolute path as a QDir object.
Definition: qfileinfo.cpp:873
virtual QString owner(FileOwner) const
If owner is OwnerUser return the name of the user who owns the file.
QString fileName() const
Returns the name of the file, excluding the path.
Definition: qfileinfo.cpp:726
QString completeSuffix() const
Returns the complete suffix of the file.
Definition: qfileinfo.cpp:811
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
FileName
These values are used to request a file name in a particular format.
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool exists() const
Returns true if the file exists; otherwise returns false.
Definition: qfileinfo.cpp:675
void setCaching(bool on)
If enable is true, enables caching of file information.
Definition: qfileinfo.cpp:1364
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177
The QString class provides a Unicode character string.
Definition: qstring.h:83
uint getFileFlags(QAbstractFileEngine::FileFlags) const
Definition: qfileinfo.cpp:126
QString group() const
Returns the group of the file.
Definition: qfileinfo.cpp:1167
QFile::Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permissions for the file.
Definition: qfileinfo.cpp:1228
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
uint ownerId() const
Returns the id of the owner of the file.
Definition: qfileinfo.cpp:1144
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QString completeBaseName() const
Returns the complete base name of the file without the path.
Definition: qfileinfo.cpp:792
static QFileSystemEntry absoluteName(const QFileSystemEntry &entry)
QString getFileOwner(QAbstractFileEngine::FileOwner own) const
Definition: qfileinfo.cpp:102
static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
bool caching() const
Returns true if caching is enabled; otherwise returns false.
Definition: qfileinfo.cpp:1346
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise ret...
Definition: qfileinfo.cpp:990
virtual bool caseSensitive() const
Should return true if the underlying file system is case-sensitive; otherwise return false...
QDateTime fileTimes[3]
Definition: qfileinfo_p.h:155
const char * name
bool makeAbsolute()
Converts the file&#39;s path to an absolute path if it is not already in that form.
Definition: qfileinfo.cpp:659
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
Definition: qfileinfo.cpp:468
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
Definition: qfileinfo.cpp:551
Q_CORE_EXPORT void qWarning(const char *,...)
The QAbstractFileEngine class provides an abstraction for accessing the filesystem.
const T * constData() const
Returns a const pointer to the shared data object.
Definition: qshareddata.h:84
bool isExecutable() const
Returns true if the file is executable; otherwise returns false.
Definition: qfileinfo.cpp:932
unsigned int uint
Definition: qglobal.h:996
QString owner() const
Returns the owner of the file.
Definition: qfileinfo.cpp:1128
__int64 qint64
Definition: qglobal.h:942
void detach()
Detaches all internal data.
Definition: qfileinfo.cpp:1336
bool operator==(const QFileInfo &fileinfo)
Returns true if this QFileInfo object refers to a file in the same location as fileinfo; otherwise re...
Definition: qfileinfo.cpp:439
static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data)
void setCachedFlag(uint c) const
Definition: qfileinfo_p.h:158
FileTime
These are used by the fileTime() function.
QString canonicalPath() const
Returns the file&#39;s path canonical path (excluding the file name), i.e.
Definition: qfileinfo.cpp:598
QFileInfo()
Constructs an empty QFileInfo object.
Definition: qfileinfo.cpp:310
static QString bundleName(const QFileSystemEntry &entry)
CaseSensitivity
Definition: qnamespace.h:1451
QString baseName() const
Returns the base name of the file without the path.
Definition: qfileinfo.cpp:773
int compare(const QString &s) const
Definition: qstring.cpp:5037
qint64 size() const
Returns the file size in bytes.
Definition: qfileinfo.cpp:1248
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
QString getFileName(QAbstractFileEngine::FileName) const
Definition: qfileinfo.cpp:50
bool isRoot() const
Returns true if the object points to a directory or to a symbolic link to a directory, and that directory is the root directory; otherwise returns false.
Definition: qfileinfo.cpp:1062
QString bundleName() const
Returns the name of the bundle.
Definition: qfileinfo.cpp:749
QString fileNames[QAbstractFileEngine::NFileNames]
Definition: qfileinfo_p.h:147
bool permission(QFile::Permissions permissions) const
Tests for file permissions.
Definition: qfileinfo.cpp:1209
QString suffix() const
Returns the suffix of the file.
Definition: qfileinfo.cpp:834
bool isRelative() const
Returns true if the file path name is relative, otherwise returns false if the path is absolute (e...
Definition: qfileinfo.cpp:642
QDateTime & getFileTime(QAbstractFileEngine::FileTime) const
Definition: qfileinfo.cpp:187
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
Definition: qfileinfo.cpp:971
uint groupId() const
Returns the id of the group the file belongs to.
Definition: qfileinfo.cpp:1183
QString filePath() const
bool isBundle() const
Returns true if this object points to a bundle or to a symbolic link to a bundle on Mac OS X; otherwi...
Definition: qfileinfo.cpp:1014
bool isRelative() const
virtual QDateTime fileTime(FileTime time) const
If time is CreationTime, return when the file was created.
QString readLink() const
Use symLinkTarget() instead.
Definition: qfileinfo.cpp:1110
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151
QString filePath(const QString &fileName) const
Returns the path name of a file in the directory.
Definition: qdir.cpp:678
bool isReadable() const
Returns true if the user can read the file; otherwise returns false.
Definition: qfileinfo.cpp:896
QString path() const
Returns the file&#39;s path.
Definition: qfileinfo.cpp:615
bool isSymLink() const
Returns true if this object points to a symbolic link (or to a shortcut on Windows); otherwise return...
Definition: qfileinfo.cpp:1044
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
QString filePath() const
Returns the file name, including the path (which may be absolute or relative).
Definition: qfileinfo.cpp:707
bool isWritable() const
Returns true if the user can write to the file; otherwise returns false.
Definition: qfileinfo.cpp:914
QString absolutePath() const
Returns a file&#39;s path absolute path.
Definition: qfileinfo.cpp:577
QString fileOwners[2]
Definition: qfileinfo_p.h:148
QString path() const
~QFileInfo()
Destroys the QFileInfo and frees its resources.
Definition: qfileinfo.cpp:367
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
QDateTime lastModified() const
Returns the date and time when the file was last modified.
Definition: qfileinfo.cpp:1296