src/corelib/io/qfileinfo.cpp
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtCore module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qplatformdefs.h"
       
    43 #include "qfileinfo.h"
       
    44 #include "qdatetime.h"
       
    45 #include "qabstractfileengine.h"
       
    46 #include "qfsfileengine_p.h"
       
    47 #include "qglobal.h"
       
    48 #include "qatomic.h"
       
    49 #include "qhash.h"
       
    50 #include "qdir.h"
       
    51 #include "qfileinfo_p.h"
       
    52 
       
    53 QT_BEGIN_NAMESPACE
       
    54 
       
    55 QFileInfoPrivate::QFileInfoPrivate(const QFileInfo *copy)
       
    56 {
       
    57     if(copy) {
       
    58         copy->d_func()->data->ref.ref();
       
    59         data = copy->d_func()->data;
       
    60     } else {
       
    61         data = new QFileInfoPrivate::Data;
       
    62     }
       
    63 }
       
    64 
       
    65 QFileInfoPrivate::~QFileInfoPrivate()
       
    66 {
       
    67     if (!data->ref.deref())
       
    68         delete data;
       
    69     data = 0;
       
    70 }
       
    71 
       
    72 void QFileInfoPrivate::initFileEngine(const QString &file)
       
    73 {
       
    74     detach();
       
    75     delete data->fileEngine;
       
    76     data->fileEngine = 0;
       
    77     data->clear();
       
    78     data->fileEngine = QAbstractFileEngine::create(file);
       
    79     data->fileName = file;
       
    80 }
       
    81 
       
    82 bool QFileInfoPrivate::hasAccess(Access access) const
       
    83 {
       
    84     if (!(getFileFlags(QAbstractFileEngine::FileInfoAll) & QAbstractFileEngine::LocalDiskFlag)) {
       
    85         switch (access) {
       
    86         case ReadAccess:
       
    87             return getFileFlags(QAbstractFileEngine::ReadUserPerm);
       
    88         case WriteAccess:
       
    89             return getFileFlags(QAbstractFileEngine::WriteUserPerm);
       
    90         case ExecuteAccess:
       
    91             return getFileFlags(QAbstractFileEngine::ExeUserPerm);
       
    92         default:
       
    93             return false;
       
    94         }
       
    95     }
       
    96 
       
    97     int mode = 0;
       
    98     switch (access) {
       
    99     case ReadAccess:
       
   100         mode = R_OK;
       
   101         break;
       
   102     case WriteAccess:
       
   103         mode = W_OK;
       
   104         break;
       
   105     case ExecuteAccess:
       
   106         mode = X_OK;
       
   107         break;
       
   108     };
       
   109 #ifdef Q_OS_UNIX
       
   110     return QT_ACCESS(QFile::encodeName(data->fileName).data(), mode) == 0;
       
   111 #endif
       
   112 #ifdef Q_OS_WIN
       
   113     if ((access == ReadAccess && !getFileFlags(QAbstractFileEngine::ReadUserPerm))
       
   114         || (access == WriteAccess && !getFileFlags(QAbstractFileEngine::WriteUserPerm))) {
       
   115         return false;
       
   116     }
       
   117     if (access == ExecuteAccess)
       
   118         return getFileFlags(QAbstractFileEngine::ExeUserPerm);
       
   119 
       
   120     return ::_waccess((wchar_t*)QFSFileEnginePrivate::longFileName(data->fileName).utf16(), mode) == 0;
       
   121 #endif
       
   122     return false;
       
   123 }
       
   124 
       
   125 void QFileInfoPrivate::detach()
       
   126 {
       
   127     qAtomicDetach(data);
       
   128 }
       
   129 
       
   130 QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const
       
   131 {
       
   132     if(data->cache_enabled && !data->fileNames[(int)name].isNull())
       
   133         return data->fileNames[(int)name];
       
   134     QString ret = data->fileEngine->fileName(name);
       
   135     if(data->cache_enabled)
       
   136         data->fileNames[(int)name] = ret;
       
   137     return ret;
       
   138 }
       
   139 
       
   140 uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const
       
   141 {
       
   142     // We split the testing into tests for for LinkType, BundleType and the rest.
       
   143     // In order to determine if a file is a symlink or not, we have to lstat().
       
   144     // If we're not interested in that information, we might as well avoid one
       
   145     // extra syscall. Bundle detecton on Mac can be slow, expecially on network
       
   146     // paths, so we separate out that as well.
       
   147 
       
   148     QAbstractFileEngine::FileFlags flags;
       
   149     if (!data->getCachedFlag(CachedFileFlags)) {
       
   150         QAbstractFileEngine::FileFlags req = QAbstractFileEngine::FileInfoAll;
       
   151         req &= (~QAbstractFileEngine::LinkType);
       
   152         req &= (~QAbstractFileEngine::BundleType);
       
   153 
       
   154         flags = data->fileEngine->fileFlags(req);
       
   155         data->setCachedFlag(CachedFileFlags);
       
   156         data->fileFlags |= uint(flags);
       
   157     } else {
       
   158         flags = QAbstractFileEngine::FileFlags(data->fileFlags & request);
       
   159     }
       
   160 
       
   161     if (request & QAbstractFileEngine::LinkType) {
       
   162         if (!data->getCachedFlag(CachedLinkTypeFlag)) {
       
   163             QAbstractFileEngine::FileFlags linkflag;
       
   164             linkflag = data->fileEngine->fileFlags(QAbstractFileEngine::LinkType);
       
   165 
       
   166             data->setCachedFlag(CachedLinkTypeFlag);
       
   167             data->fileFlags |= uint(linkflag);
       
   168             flags |= linkflag;
       
   169         }
       
   170     }
       
   171 
       
   172     if (request & QAbstractFileEngine::BundleType) {
       
   173         if (!data->getCachedFlag(CachedBundleTypeFlag)) {
       
   174             QAbstractFileEngine::FileFlags bundleflag;
       
   175             bundleflag = data->fileEngine->fileFlags(QAbstractFileEngine::BundleType);
       
   176 
       
   177             data->setCachedFlag(CachedBundleTypeFlag);
       
   178             data->fileFlags |= uint(bundleflag);
       
   179             flags |= bundleflag;
       
   180         }
       
   181     }
       
   182 
       
   183     // no else branch
       
   184     // if we had it cached, it was caught in the previous else branch
       
   185 
       
   186     return flags & request;
       
   187 }
       
   188 
       
   189 QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const
       
   190 {
       
   191     if (!data->cache_enabled)
       
   192         data->clearFlags();
       
   193     if(request == QAbstractFileEngine::CreationTime) {
       
   194         if(data->getCachedFlag(CachedCTime))
       
   195             return data->fileTimes[request];
       
   196         data->setCachedFlag(CachedCTime);
       
   197         return (data->fileTimes[request] = data->fileEngine->fileTime(request));
       
   198     }
       
   199     if(request == QAbstractFileEngine::ModificationTime) {
       
   200         if(data->getCachedFlag(CachedMTime))
       
   201             return data->fileTimes[request];
       
   202         data->setCachedFlag(CachedMTime);
       
   203         return (data->fileTimes[request] = data->fileEngine->fileTime(request));
       
   204     }
       
   205     if(request == QAbstractFileEngine::AccessTime) {
       
   206         if(data->getCachedFlag(CachedATime))
       
   207             return data->fileTimes[request];
       
   208         data->setCachedFlag(CachedATime);
       
   209         return (data->fileTimes[request] = data->fileEngine->fileTime(request));
       
   210     }
       
   211     return data->fileTimes[0]; //cannot really happen
       
   212 }
       
   213 
       
   214 //************* QFileInfo
       
   215 
       
   216 /*!
       
   217     \class QFileInfo
       
   218     \reentrant
       
   219     \brief The QFileInfo class provides system-independent file information.
       
   220 
       
   221     \ingroup io
       
   222     \ingroup shared
       
   223 
       
   224     QFileInfo provides information about a file's name and position
       
   225     (path) in the file system, its access rights and whether it is a
       
   226     directory or symbolic link, etc. The file's size and last
       
   227     modified/read times are also available. QFileInfo can also be
       
   228     used to obtain information about a Qt \l{resource
       
   229     system}{resource}.
       
   230 
       
   231     A QFileInfo can point to a file with either a relative or an
       
   232     absolute file path. Absolute file paths begin with the directory
       
   233     separator "/" (or with a drive specification on Windows). Relative
       
   234     file names begin with a directory name or a file name and specify
       
   235     a path relative to the current working directory. An example of an
       
   236     absolute path is the string "/tmp/quartz". A relative path might
       
   237     look like "src/fatlib". You can use the function isRelative() to
       
   238     check whether a QFileInfo is using a relative or an absolute file
       
   239     path. You can call the function makeAbsolute() to convert a
       
   240     relative QFileInfo's path to an absolute path.
       
   241 
       
   242     The file that the QFileInfo works on is set in the constructor or
       
   243     later with setFile(). Use exists() to see if the file exists and
       
   244     size() to get its size.
       
   245 
       
   246     The file's type is obtained with isFile(), isDir() and
       
   247     isSymLink(). The symLinkTarget() function provides the name of the file
       
   248     the symlink points to.
       
   249 
       
   250     On Unix (including Mac OS X), the symlink has the same size() has
       
   251     the file it points to, because Unix handles symlinks
       
   252     transparently; similarly, opening a symlink using QFile
       
   253     effectively opens the link's target. For example:
       
   254 
       
   255     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 0
       
   256 
       
   257     On Windows, symlinks (shortcuts) are \c .lnk files. The reported
       
   258     size() is that of the symlink (not the link's target), and
       
   259     opening a symlink using QFile opens the \c .lnk file. For
       
   260     example:
       
   261 
       
   262     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 1
       
   263 
       
   264     Elements of the file's name can be extracted with path() and
       
   265     fileName(). The fileName()'s parts can be extracted with
       
   266     baseName(), suffix() or completeSuffix(). QFileInfo objects to
       
   267     directories created by Qt classes will not have a trailing file
       
   268     separator. If you wish to use trailing separators in your own file
       
   269     info objects, just append one to the file name given to the constructors
       
   270     or setFile().
       
   271 
       
   272     The file's dates are returned by created(), lastModified() and
       
   273     lastRead(). Information about the file's access permissions is
       
   274     obtained with isReadable(), isWritable() and isExecutable(). The
       
   275     file's ownership is available from owner(), ownerId(), group() and
       
   276     groupId(). You can examine a file's permissions and ownership in a
       
   277     single statement using the permission() function.
       
   278 
       
   279     \section1 Performance Issues
       
   280 
       
   281     Some of QFileInfo's functions query the file system, but for
       
   282     performance reasons, some functions only operate on the
       
   283     file name itself. For example: To return the absolute path of
       
   284     a relative file name, absolutePath() has to query the file system.
       
   285     The path() function, however, can work on the file name directly,
       
   286     and so it is faster.
       
   287 
       
   288     \note To speed up performance, QFileInfo caches information about
       
   289     the file.
       
   290 
       
   291     To speed up performance, QFileInfo caches information about the
       
   292     file. Because files can be changed by other users or programs, or
       
   293     even by other parts of the same program, there is a function that
       
   294     refreshes the file information: refresh(). If you want to switch
       
   295     off a QFileInfo's caching and force it to access the file system
       
   296     every time you request information from it call setCaching(false).
       
   297 
       
   298     \sa QDir, QFile
       
   299 */
       
   300 
       
   301 /*!
       
   302     Constructs an empty QFileInfo object.
       
   303 
       
   304     Note that an empty QFileInfo object contain no file reference.
       
   305 
       
   306     \sa setFile()
       
   307 */
       
   308 
       
   309 QFileInfo::QFileInfo() : d_ptr(new QFileInfoPrivate())
       
   310 {
       
   311 }
       
   312 
       
   313 /*!
       
   314     Constructs a new QFileInfo that gives information about the given
       
   315     file. The \a file can also include an absolute or relative path.
       
   316 
       
   317     \sa setFile(), isRelative(), QDir::setCurrent(), QDir::isRelativePath()
       
   318 */
       
   319 
       
   320 QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate())
       
   321 {
       
   322     d_ptr->initFileEngine(file);
       
   323 }
       
   324 
       
   325 /*!
       
   326     Constructs a new QFileInfo that gives information about file \a
       
   327     file.
       
   328 
       
   329     If the \a file has a relative path, the QFileInfo will also have a
       
   330     relative path.
       
   331 
       
   332     \sa isRelative()
       
   333 */
       
   334 
       
   335 QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate())
       
   336 {
       
   337     d_ptr->initFileEngine(file.fileName());
       
   338 }
       
   339 
       
   340 /*!
       
   341     Constructs a new QFileInfo that gives information about the given
       
   342     \a file in the directory \a dir.
       
   343 
       
   344     If \a dir has a relative path, the QFileInfo will also have a
       
   345     relative path.
       
   346 
       
   347     If \a file is an absolute path, then the directory specified
       
   348     by \a dir will be disregarded.
       
   349 
       
   350     \sa isRelative()
       
   351 */
       
   352 
       
   353 QFileInfo::QFileInfo(const QDir &dir, const QString &file) : d_ptr(new QFileInfoPrivate())
       
   354 {
       
   355     d_ptr->initFileEngine(dir.filePath(file));
       
   356 }
       
   357 
       
   358 /*!
       
   359     Constructs a new QFileInfo that is a copy of the given \a fileinfo.
       
   360 */
       
   361 
       
   362 QFileInfo::QFileInfo(const QFileInfo &fileinfo) : d_ptr(new QFileInfoPrivate(&fileinfo))
       
   363 {
       
   364 
       
   365 }
       
   366 
       
   367 /*!
       
   368     Destroys the QFileInfo and frees its resources.
       
   369 */
       
   370 
       
   371 
       
   372 QFileInfo::~QFileInfo()
       
   373 {
       
   374 }
       
   375 
       
   376 /*!
       
   377     \fn bool QFileInfo::operator!=(const QFileInfo &fileinfo)
       
   378 
       
   379     Returns true if this QFileInfo object refers to a different file
       
   380     than the one specified by \a fileinfo; otherwise returns false.
       
   381 
       
   382     \sa operator==()
       
   383 */
       
   384 
       
   385 /*!
       
   386     \overload
       
   387     \fn bool QFileInfo::operator!=(const QFileInfo &fileinfo) const
       
   388 */
       
   389 
       
   390 /*!
       
   391     \overload
       
   392 */
       
   393 bool QFileInfo::operator==(const QFileInfo &fileinfo) const
       
   394 {
       
   395     Q_D(const QFileInfo);
       
   396     // ### Qt 5: understand long and short file names on Windows
       
   397     // ### (GetFullPathName()).
       
   398     if(fileinfo.d_func()->data == d->data)
       
   399         return true;
       
   400     if(!d->data->fileEngine || !fileinfo.d_func()->data->fileEngine)
       
   401         return false;
       
   402     if(d->data->fileEngine->caseSensitive() != fileinfo.d_func()->data->fileEngine->caseSensitive())
       
   403         return false;
       
   404     if(fileinfo.size() == size()) { //if the size isn't the same...
       
   405         QString file1 = canonicalFilePath(),
       
   406                 file2 = fileinfo.canonicalFilePath();
       
   407         if(file1.length() == file2.length()) {
       
   408             if(!fileinfo.d_func()->data->fileEngine->caseSensitive()) {
       
   409                 for(int i = 0; i < file1.length(); i++) {
       
   410                     if(file1.at(i).toLower() != file2.at(i).toLower())
       
   411                         return false;
       
   412                 }
       
   413                 return true;
       
   414             }
       
   415             return (file1 == file2);
       
   416         }
       
   417     }
       
   418     return false;
       
   419 }
       
   420 
       
   421 /*!
       
   422     Returns true if this QFileInfo object refers to a file in the same
       
   423     location as \a fileinfo; otherwise returns false.
       
   424 
       
   425     Note that the result of comparing two empty QFileInfo objects,
       
   426     containing no file references, is undefined.
       
   427 
       
   428     \warning This will not compare two different symbolic links
       
   429     pointing to the same file.
       
   430 
       
   431     \warning Long and short file names that refer to the same file on Windows
       
   432     are treated as if they referred to different files.
       
   433 
       
   434     \sa operator!=()
       
   435 */
       
   436 bool QFileInfo::operator==(const QFileInfo &fileinfo)
       
   437 {
       
   438     return const_cast<const QFileInfo *>(this)->operator==(fileinfo);
       
   439 }
       
   440 
       
   441 /*!
       
   442     Makes a copy of the given \a fileinfo and assigns it to this QFileInfo.
       
   443 */
       
   444 
       
   445 QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo)
       
   446 {
       
   447     Q_D(QFileInfo);
       
   448     qAtomicAssign(d->data, fileinfo.d_func()->data);
       
   449     return *this;
       
   450 }
       
   451 
       
   452 /*!
       
   453     Sets the file that the QFileInfo provides information about to \a
       
   454     file.
       
   455 
       
   456     The \a file can also include an absolute or relative file path.
       
   457     Absolute paths begin with the directory separator (e.g. "/" under
       
   458     Unix) or a drive specification (under Windows). Relative file
       
   459     names begin with a directory name or a file name and specify a
       
   460     path relative to the current directory.
       
   461 
       
   462     Example:
       
   463     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 2
       
   464 
       
   465     \sa isRelative(), QDir::setCurrent(), QDir::isRelativePath()
       
   466 */
       
   467 
       
   468 void QFileInfo::setFile(const QString &file)
       
   469 {
       
   470     *this = QFileInfo(file);
       
   471 }
       
   472 
       
   473 /*!
       
   474     \overload
       
   475 
       
   476     Sets the file that the QFileInfo provides information about to \a
       
   477     file.
       
   478 
       
   479     If \a file includes a relative path, the QFileInfo will also have
       
   480     a relative path.
       
   481 
       
   482     \sa isRelative()
       
   483 */
       
   484 
       
   485 void QFileInfo::setFile(const QFile &file)
       
   486 {
       
   487     *this = QFileInfo(file.fileName());
       
   488 }
       
   489 
       
   490 /*!
       
   491     \overload
       
   492 
       
   493     Sets the file that the QFileInfo provides information about to \a
       
   494     file in directory \a dir.
       
   495 
       
   496     If \a file includes a relative path, the QFileInfo will also
       
   497     have a relative path.
       
   498 
       
   499     \sa isRelative()
       
   500 */
       
   501 
       
   502 void QFileInfo::setFile(const QDir &dir, const QString &file)
       
   503 {
       
   504     *this = QFileInfo(dir.filePath(file));
       
   505 }
       
   506 
       
   507 /*!
       
   508     Returns an absolute path including the file name.
       
   509 
       
   510     The absolute path name consists of the full path and the file
       
   511     name. On Unix this will always begin with the root, '/',
       
   512     directory. On Windows this will always begin 'D:/' where D is a
       
   513     drive letter, except for network shares that are not mapped to a
       
   514     drive letter, in which case the path will begin '//sharename/'.
       
   515     QFileInfo will uppercase drive letters. Note that QDir does not do
       
   516     this. The code snippet below shows this.
       
   517 
       
   518     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp newstuff
       
   519 
       
   520     This function returns the same as filePath(), unless isRelative()
       
   521     is true. In contrast to canonicalFilePath(), symbolic links or
       
   522     redundant "." or ".." elements are not necessarily removed.
       
   523 
       
   524     If the QFileInfo is empty it returns QDir::currentPath().
       
   525 
       
   526     \sa filePath(), canonicalFilePath(), isRelative()
       
   527 */
       
   528 QString QFileInfo::absoluteFilePath() const
       
   529 {
       
   530     Q_D(const QFileInfo);
       
   531     if(!d->data->fileEngine)
       
   532         return QLatin1String("");
       
   533     return d->getFileName(QAbstractFileEngine::AbsoluteName);
       
   534 }
       
   535 
       
   536 /*!
       
   537   Returns the canonical path including the file name, i.e. an absolute
       
   538   path without symbolic links or redundant "." or ".." elements.
       
   539 
       
   540   If the file does not exist, canonicalFilePath() returns an empty
       
   541   string.
       
   542 
       
   543   \sa filePath(), absoluteFilePath(), dir()
       
   544 */
       
   545 
       
   546 QString QFileInfo::canonicalFilePath() const
       
   547 {
       
   548     Q_D(const QFileInfo);
       
   549     if(!d->data->fileEngine)
       
   550         return QLatin1String("");
       
   551     return d->getFileName(QAbstractFileEngine::CanonicalName);
       
   552 }
       
   553 
       
   554 
       
   555 /*!
       
   556     Returns a file's path absolute path. This doesn't include the
       
   557     file name.
       
   558 
       
   559     On Unix the absolute path will always begin with the root, '/',
       
   560     directory. On Windows this will always begin 'D:/' where D is a
       
   561     drive letter, except for network shares that are not mapped to a
       
   562     drive letter, in which case the path will begin '//sharename/'.
       
   563 
       
   564     In contrast to canonicalPath() symbolic links or redundant "." or
       
   565     ".." elements are not necessarily removed.
       
   566 
       
   567     \warning If the QFileInfo object was created with an empty QString,
       
   568               the behavior of this function is undefined.
       
   569 
       
   570     \sa absoluteFilePath(), path(), canonicalPath(), fileName(), isRelative()
       
   571 */
       
   572 
       
   573 QString QFileInfo::absolutePath() const
       
   574 {
       
   575     Q_D(const QFileInfo);
       
   576     if(!d->data->fileEngine)
       
   577         return QLatin1String("");
       
   578     return d->getFileName(QAbstractFileEngine::AbsolutePathName);
       
   579 }
       
   580 
       
   581 /*!
       
   582     Returns the file's path canonical path (excluding the file name),
       
   583     i.e. an absolute path without symbolic links or redundant "." or ".." elements.
       
   584 
       
   585     If the file does not exist, canonicalPath() returns an empty string.
       
   586 
       
   587     \sa path(), absolutePath()
       
   588 */
       
   589 
       
   590 QString QFileInfo::canonicalPath() const
       
   591 {
       
   592     Q_D(const QFileInfo);
       
   593     if(!d->data->fileEngine)
       
   594         return QLatin1String("");
       
   595     return d->getFileName(QAbstractFileEngine::CanonicalPathName);
       
   596 }
       
   597 
       
   598 
       
   599 /*!
       
   600     Returns the file's path. This doesn't include the file name.
       
   601 
       
   602     Note that, if this QFileInfo object is given a path ending in a
       
   603     slash, the name of the file is considered empty and this function
       
   604     will return the entire path.
       
   605 
       
   606     \sa filePath(), absolutePath(), canonicalPath(), dir(), fileName(), isRelative()
       
   607 */
       
   608 
       
   609 QString QFileInfo::path() const
       
   610 {
       
   611     Q_D(const QFileInfo);
       
   612     if(!d->data->fileEngine)
       
   613         return QLatin1String("");
       
   614     return d->getFileName(QAbstractFileEngine::PathName);
       
   615 }
       
   616 
       
   617 /*!
       
   618     \fn bool QFileInfo::isAbsolute() const
       
   619 
       
   620     Returns true if the file path name is absolute, otherwise returns
       
   621     false if the path is relative.
       
   622 
       
   623     \sa isRelative()
       
   624 */
       
   625 
       
   626 /*!
       
   627     Returns true if the file path name is relative, otherwise returns
       
   628     false if the path is absolute (e.g. under Unix a path is absolute
       
   629     if it begins with a "/").
       
   630 
       
   631     \sa isAbsolute()
       
   632 */
       
   633 
       
   634 bool QFileInfo::isRelative() const
       
   635 {
       
   636     Q_D(const QFileInfo);
       
   637     if(!d->data->fileEngine)
       
   638         return true;
       
   639     return d->data->fileEngine->isRelativePath();
       
   640 }
       
   641 
       
   642 
       
   643 /*!
       
   644     Converts the file's path to an absolute path if it is not already in that form.
       
   645     Returns true to indicate that the path was converted; otherwise returns false
       
   646     to indicate that the path was already absolute.
       
   647 
       
   648     \sa filePath(), isRelative()
       
   649 */
       
   650 
       
   651 bool QFileInfo::makeAbsolute()
       
   652 {
       
   653     Q_D(QFileInfo);
       
   654     if(!d->data->fileEngine || !d->data->fileEngine->isRelativePath())
       
   655         return false;
       
   656     QString absFileName = d->getFileName(QAbstractFileEngine::AbsoluteName);
       
   657     d->initFileEngine(absFileName);
       
   658     return true;
       
   659 }
       
   660 
       
   661 /*!
       
   662     Returns true if the file exists; otherwise returns false.
       
   663 
       
   664     \note If the file is a symlink that points to a non existing
       
   665      file, false is returned.
       
   666 */
       
   667 
       
   668 bool QFileInfo::exists() const
       
   669 {
       
   670     Q_D(const QFileInfo);
       
   671     if(!d->data->fileEngine)
       
   672         return false;
       
   673     return d->getFileFlags(QAbstractFileEngine::ExistsFlag);
       
   674 }
       
   675 
       
   676 /*!
       
   677     Refreshes the information about the file, i.e. reads in information
       
   678     from the file system the next time a cached property is fetched.
       
   679 
       
   680    \note On Windows CE, there might be a delay for the file system driver
       
   681     to detect changes on the file.
       
   682 */
       
   683 
       
   684 void QFileInfo::refresh()
       
   685 {
       
   686     Q_D(QFileInfo);
       
   687     d->reset();
       
   688 }
       
   689 
       
   690 /*!
       
   691     Returns the file name, including the path (which may be absolute
       
   692     or relative).
       
   693 
       
   694     \sa absoluteFilePath(), canonicalFilePath(), isRelative()
       
   695 */
       
   696 
       
   697 QString QFileInfo::filePath() const
       
   698 {
       
   699     Q_D(const QFileInfo);
       
   700     if(!d->data->fileEngine)
       
   701         return QLatin1String("");
       
   702     return d->getFileName(QAbstractFileEngine::DefaultName);
       
   703 }
       
   704 
       
   705 /*!
       
   706     Returns the name of the file, excluding the path.
       
   707 
       
   708     Example:
       
   709     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 3
       
   710 
       
   711     Note that, if this QFileInfo object is given a path ending in a
       
   712     slash, the name of the file is considered empty.
       
   713 
       
   714     \sa isRelative(), filePath(), baseName(), extension()
       
   715 */
       
   716 
       
   717 QString QFileInfo::fileName() const
       
   718 {
       
   719     Q_D(const QFileInfo);
       
   720     if(!d->data->fileEngine)
       
   721         return QLatin1String("");
       
   722     return d->getFileName(QAbstractFileEngine::BaseName);
       
   723 }
       
   724 
       
   725 /*!
       
   726     \since 4.3
       
   727     Returns the name of the bundle.
       
   728 
       
   729     On Mac OS X this returns the proper localized name for a bundle if the
       
   730     path isBundle(). On all other platforms an empty QString is returned.
       
   731 
       
   732     Example:
       
   733     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 4
       
   734 
       
   735     \sa isBundle(), filePath(), baseName(), extension()
       
   736 */
       
   737 
       
   738 QString QFileInfo::bundleName() const
       
   739 {
       
   740     Q_D(const QFileInfo);
       
   741     if(!d->data->fileEngine)
       
   742         return QLatin1String("");
       
   743     return d->getFileName(QAbstractFileEngine::BundleName);
       
   744 }
       
   745 
       
   746 /*!
       
   747     Returns the base name of the file without the path.
       
   748 
       
   749     The base name consists of all characters in the file up to (but
       
   750     not including) the \e first '.' character.
       
   751 
       
   752     Example:
       
   753     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 5
       
   754 
       
   755 
       
   756     The base name of a file is computed equally on all platforms, independent
       
   757     of file naming conventions (e.g., ".bashrc" on Unix has an empty base
       
   758     name, and the suffix is "bashrc").
       
   759 
       
   760     \sa fileName(), suffix(), completeSuffix(), completeBaseName()
       
   761 */
       
   762 
       
   763 QString QFileInfo::baseName() const
       
   764 {
       
   765     Q_D(const QFileInfo);
       
   766     if(!d->data->fileEngine)
       
   767         return QLatin1String("");
       
   768     return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0);
       
   769 }
       
   770 
       
   771 /*!
       
   772     Returns the complete base name of the file without the path.
       
   773 
       
   774     The complete base name consists of all characters in the file up
       
   775     to (but not including) the \e last '.' character.
       
   776 
       
   777     Example:
       
   778     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 6
       
   779 
       
   780     \sa fileName(), suffix(), completeSuffix(), baseName()
       
   781 */
       
   782 
       
   783 QString QFileInfo::completeBaseName() const
       
   784 {
       
   785     Q_D(const QFileInfo);
       
   786     if(!d->data->fileEngine)
       
   787         return QLatin1String("");
       
   788     QString name = d->getFileName(QAbstractFileEngine::BaseName);
       
   789     int index = name.lastIndexOf(QLatin1Char('.'));
       
   790     return (index == -1) ? name : name.left(index);
       
   791 }
       
   792 
       
   793 /*!
       
   794     Returns the complete suffix of the file.
       
   795 
       
   796     The complete suffix consists of all characters in the file after
       
   797     (but not including) the first '.'.
       
   798 
       
   799     Example:
       
   800     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 7
       
   801 
       
   802     \sa fileName(), suffix(), baseName(), completeBaseName()
       
   803 */
       
   804 
       
   805 QString QFileInfo::completeSuffix() const
       
   806 {
       
   807     Q_D(const QFileInfo);
       
   808     if(!d->data->fileEngine)
       
   809         return QLatin1String("");
       
   810     QString fileName = d->getFileName(QAbstractFileEngine::BaseName);
       
   811     int firstDot = fileName.indexOf(QLatin1Char('.'));
       
   812     if (firstDot == -1)
       
   813         return QLatin1String("");
       
   814     return fileName.mid(firstDot + 1);
       
   815 }
       
   816 
       
   817 /*!
       
   818     Returns the suffix of the file.
       
   819 
       
   820     The suffix consists of all characters in the file after (but not
       
   821     including) the last '.'.
       
   822 
       
   823     Example:
       
   824     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 8
       
   825 
       
   826     The suffix of a file is computed equally on all platforms, independent of
       
   827     file naming conventions (e.g., ".bashrc" on Unix has an empty base name,
       
   828     and the suffix is "bashrc").
       
   829 
       
   830     \sa fileName(), completeSuffix(), baseName(), completeBaseName()
       
   831 */
       
   832 
       
   833 QString QFileInfo::suffix() const
       
   834 {
       
   835     Q_D(const QFileInfo);
       
   836     if(!d->data->fileEngine)
       
   837         return QLatin1String("");
       
   838     QString fileName = d->getFileName(QAbstractFileEngine::BaseName);
       
   839     int lastDot = fileName.lastIndexOf(QLatin1Char('.'));
       
   840     if (lastDot == -1)
       
   841         return QLatin1String("");
       
   842     return fileName.mid(lastDot + 1);
       
   843 }
       
   844 
       
   845 
       
   846 /*!
       
   847   Returns the path of the object's parent directory as a QDir object.
       
   848 
       
   849   \bold{Note:} The QDir returned always corresponds to the object's
       
   850   parent directory, even if the QFileInfo represents a directory.
       
   851 
       
   852   For each of the follwing, dir() returns a QDir for
       
   853   \c{"~/examples/191697"}.
       
   854 
       
   855   \snippet doc/src/snippets/fileinfo/main.cpp 0
       
   856 
       
   857   For each of the follwing, dir() returns a QDir for
       
   858   \c{"."}.
       
   859 
       
   860   \snippet doc/src/snippets/fileinfo/main.cpp 1
       
   861 
       
   862   \sa absolutePath(), filePath(), fileName(), isRelative(), absoluteDir()
       
   863 */
       
   864 
       
   865 QDir QFileInfo::dir() const
       
   866 {
       
   867     // ### Qt5: Maybe rename this to parentDirectory(), considering what it actually do?
       
   868     return QDir(path());
       
   869 }
       
   870 
       
   871 /*!
       
   872     Returns the file's absolute path as a QDir object.
       
   873 
       
   874     \sa dir(), filePath(), fileName(), isRelative()
       
   875 */
       
   876 
       
   877 QDir QFileInfo::absoluteDir() const
       
   878 {
       
   879     return QDir(absolutePath());
       
   880 }
       
   881 
       
   882 #ifdef QT3_SUPPORT
       
   883 /*!
       
   884     Use absoluteDir() or the dir() overload that takes no parameters
       
   885     instead.
       
   886 */
       
   887 QDir QFileInfo::dir(bool absPath) const
       
   888 {
       
   889     if(absPath)
       
   890         return absoluteDir();
       
   891     return dir();
       
   892 }
       
   893 #endif //QT3_SUPPORT
       
   894 
       
   895 /*!
       
   896     Returns true if the user can read the file; otherwise returns false.
       
   897 
       
   898     \sa isWritable(), isExecutable(), permission()
       
   899 */
       
   900 
       
   901 bool QFileInfo::isReadable() const
       
   902 {
       
   903     Q_D(const QFileInfo);
       
   904     if(!d->data->fileEngine)
       
   905         return false;
       
   906     return d->hasAccess(QFileInfoPrivate::ReadAccess);
       
   907 }
       
   908 
       
   909 /*!
       
   910     Returns true if the user can write to the file; otherwise returns false.
       
   911 
       
   912     \sa isReadable(), isExecutable(), permission()
       
   913 */
       
   914 
       
   915 bool QFileInfo::isWritable() const
       
   916 {
       
   917     Q_D(const QFileInfo);
       
   918     if(!d->data->fileEngine)
       
   919         return false;
       
   920     return d->hasAccess(QFileInfoPrivate::WriteAccess);
       
   921 }
       
   922 
       
   923 /*!
       
   924     Returns true if the file is executable; otherwise returns false.
       
   925 
       
   926     \sa isReadable(), isWritable(), permission()
       
   927 */
       
   928 
       
   929 bool QFileInfo::isExecutable() const
       
   930 {
       
   931     Q_D(const QFileInfo);
       
   932     if(!d->data->fileEngine)
       
   933         return false;
       
   934     return d->hasAccess(QFileInfoPrivate::ExecuteAccess);
       
   935 }
       
   936 
       
   937 /*!
       
   938     Returns true if this is a `hidden' file; otherwise returns false.
       
   939 
       
   940     \bold{Note:} This function returns true for the special entries
       
   941     "." and ".." on Unix, even though QDir::entryList threats them as shown.
       
   942 */
       
   943 bool QFileInfo::isHidden() const
       
   944 {
       
   945     Q_D(const QFileInfo);
       
   946     if(!d->data->fileEngine)
       
   947         return false;
       
   948     return d->getFileFlags(QAbstractFileEngine::HiddenFlag);
       
   949 }
       
   950 
       
   951 /*!
       
   952     Returns true if this object points to a file or to a symbolic
       
   953     link to a file. Returns false if the
       
   954     object points to something which isn't a file, such as a directory.
       
   955 
       
   956     \sa isDir(), isSymLink(), isBundle()
       
   957 */
       
   958 
       
   959 bool QFileInfo::isFile() const
       
   960 {
       
   961     Q_D(const QFileInfo);
       
   962     if(!d->data->fileEngine)
       
   963         return false;
       
   964     return d->getFileFlags(QAbstractFileEngine::FileType);
       
   965 }
       
   966 
       
   967 /*!
       
   968     Returns true if this object points to a directory or to a symbolic
       
   969     link to a directory; otherwise returns false.
       
   970 
       
   971     \sa isFile(), isSymLink(), isBundle()
       
   972 */
       
   973 
       
   974 bool QFileInfo::isDir() const
       
   975 {
       
   976     Q_D(const QFileInfo);
       
   977     if(!d->data->fileEngine)
       
   978         return false;
       
   979     return d->getFileFlags(QAbstractFileEngine::DirectoryType);
       
   980 }
       
   981 
       
   982 
       
   983 /*!
       
   984     \since 4.3
       
   985     Returns true if this object points to a bundle or to a symbolic
       
   986     link to a bundle on Mac OS X; otherwise returns false.
       
   987 
       
   988     \sa isDir(), isSymLink(), isFile()
       
   989 */
       
   990 
       
   991 bool QFileInfo::isBundle() const
       
   992 {
       
   993     Q_D(const QFileInfo);
       
   994     if(!d->data->fileEngine)
       
   995         return false;
       
   996     return d->getFileFlags(QAbstractFileEngine::BundleType);
       
   997 }
       
   998 
       
   999 /*!
       
  1000     Returns true if this object points to a symbolic link (or to a
       
  1001     shortcut on Windows); otherwise returns false.
       
  1002 
       
  1003     On Unix (including Mac OS X), opening a symlink effectively opens
       
  1004     the \l{symLinkTarget()}{link's target}. On Windows, it opens the \c
       
  1005     .lnk file itself.
       
  1006 
       
  1007     Example:
       
  1008 
       
  1009     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 9
       
  1010 
       
  1011     \note If the symlink points to a non existing file, exists() returns
       
  1012      false.
       
  1013 
       
  1014     \sa isFile(), isDir(), symLinkTarget()
       
  1015 */
       
  1016 
       
  1017 bool QFileInfo::isSymLink() const
       
  1018 {
       
  1019     Q_D(const QFileInfo);
       
  1020     if(!d->data->fileEngine)
       
  1021         return false;
       
  1022     return d->getFileFlags(QAbstractFileEngine::LinkType);
       
  1023 }
       
  1024 
       
  1025 /*!
       
  1026   Returns true if the object points to a directory or to a symbolic
       
  1027   link to a directory, and that directory is the root directory; otherwise
       
  1028   returns false.
       
  1029 */
       
  1030 
       
  1031 bool QFileInfo::isRoot() const
       
  1032 {
       
  1033     Q_D(const QFileInfo);
       
  1034     if (!d->data->fileEngine)
       
  1035         return true;
       
  1036     return d->getFileFlags(QAbstractFileEngine::RootFlag);
       
  1037 }
       
  1038 
       
  1039 /*!
       
  1040     \fn QString QFileInfo::symLinkTarget() const
       
  1041     \since 4.2
       
  1042 
       
  1043     Returns the absolute path to the file or directory a symlink (or shortcut
       
  1044     on Windows) points to, or a an empty string if the object isn't a symbolic
       
  1045     link.
       
  1046 
       
  1047     This name may not represent an existing file; it is only a string.
       
  1048     QFileInfo::exists() returns true if the symlink points to an
       
  1049     existing file.
       
  1050 
       
  1051     \sa exists(), isSymLink(), isDir(), isFile()
       
  1052 */
       
  1053 
       
  1054 /*!
       
  1055     \obsolete
       
  1056 
       
  1057     Use symLinkTarget() instead.
       
  1058 */
       
  1059 QString QFileInfo::readLink() const
       
  1060 {
       
  1061     Q_D(const QFileInfo);
       
  1062     if(!d->data->fileEngine)
       
  1063         return QLatin1String("");
       
  1064     return d->getFileName(QAbstractFileEngine::LinkName);
       
  1065 }
       
  1066 
       
  1067 /*!
       
  1068     Returns the owner of the file. On systems where files
       
  1069     do not have owners, or if an error occurs, an empty string is
       
  1070     returned.
       
  1071 
       
  1072     This function can be time consuming under Unix (in the order of
       
  1073     milliseconds).
       
  1074 
       
  1075     \sa ownerId(), group(), groupId()
       
  1076 */
       
  1077 
       
  1078 QString QFileInfo::owner() const
       
  1079 {
       
  1080     Q_D(const QFileInfo);
       
  1081     if(!d->data->fileEngine)
       
  1082         return QLatin1String("");
       
  1083     return d->data->fileEngine->owner(QAbstractFileEngine::OwnerUser);
       
  1084 }
       
  1085 
       
  1086 /*!
       
  1087     Returns the id of the owner of the file.
       
  1088 
       
  1089     On Windows and on systems where files do not have owners this
       
  1090     function returns ((uint) -2).
       
  1091 
       
  1092     \sa owner(), group(), groupId()
       
  1093 */
       
  1094 
       
  1095 uint QFileInfo::ownerId() const
       
  1096 {
       
  1097     Q_D(const QFileInfo);
       
  1098     if(!d->data->fileEngine)
       
  1099         return 0;
       
  1100     return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerUser);
       
  1101 }
       
  1102 
       
  1103 /*!
       
  1104     Returns the group of the file. On Windows, on systems where files
       
  1105     do not have groups, or if an error occurs, an empty string is
       
  1106     returned.
       
  1107 
       
  1108     This function can be time consuming under Unix (in the order of
       
  1109     milliseconds).
       
  1110 
       
  1111     \sa groupId(), owner(), ownerId()
       
  1112 */
       
  1113 
       
  1114 QString QFileInfo::group() const
       
  1115 {
       
  1116     Q_D(const QFileInfo);
       
  1117     if(!d->data->fileEngine)
       
  1118         return QLatin1String("");
       
  1119     return d->data->fileEngine->owner(QAbstractFileEngine::OwnerGroup);
       
  1120 }
       
  1121 
       
  1122 /*!
       
  1123     Returns the id of the group the file belongs to.
       
  1124 
       
  1125     On Windows and on systems where files do not have groups this
       
  1126     function always returns (uint) -2.
       
  1127 
       
  1128     \sa group(), owner(), ownerId()
       
  1129 */
       
  1130 
       
  1131 uint QFileInfo::groupId() const
       
  1132 {
       
  1133     Q_D(const QFileInfo);
       
  1134     if(!d->data->fileEngine)
       
  1135         return 0;
       
  1136     return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup);
       
  1137 }
       
  1138 
       
  1139 /*!
       
  1140     Tests for file permissions. The \a permissions argument can be
       
  1141     several flags of type QFile::Permissions OR-ed together to check
       
  1142     for permission combinations.
       
  1143 
       
  1144     On systems where files do not have permissions this function
       
  1145     always returns true.
       
  1146 
       
  1147     Example:
       
  1148     \snippet doc/src/snippets/code/src_corelib_io_qfileinfo.cpp 10
       
  1149 
       
  1150     \sa isReadable(), isWritable(), isExecutable()
       
  1151 */
       
  1152 
       
  1153 bool QFileInfo::permission(QFile::Permissions permissions) const
       
  1154 {
       
  1155     Q_D(const QFileInfo);
       
  1156     if(!d->data->fileEngine)
       
  1157         return false;
       
  1158     return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions;
       
  1159 }
       
  1160 
       
  1161 /*!
       
  1162     Returns the complete OR-ed together combination of
       
  1163     QFile::Permissions for the file.
       
  1164 */
       
  1165 
       
  1166 QFile::Permissions QFileInfo::permissions() const
       
  1167 {
       
  1168     Q_D(const QFileInfo);
       
  1169     if(!d->data->fileEngine)
       
  1170         return 0;
       
  1171     return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask);
       
  1172 }
       
  1173 
       
  1174 
       
  1175 /*!
       
  1176     Returns the file size in bytes. If the file does not exist or cannot be
       
  1177     fetched, 0 is returned.
       
  1178 
       
  1179     \sa exists()
       
  1180 */
       
  1181 
       
  1182 qint64 QFileInfo::size() const
       
  1183 {
       
  1184     Q_D(const QFileInfo);
       
  1185     if(!d->data->fileEngine)
       
  1186         return 0;
       
  1187     if(!d->data->getCachedFlag(QFileInfoPrivate::CachedSize)) {
       
  1188         d->data->setCachedFlag(QFileInfoPrivate::CachedSize);
       
  1189         d->data->fileSize = d->data->fileEngine->size();
       
  1190     }
       
  1191     return d->data->fileSize;
       
  1192 }
       
  1193 
       
  1194 /*!
       
  1195     Returns the date and time when the file was created.
       
  1196 
       
  1197     On most Unix systems, this function returns the time of the last
       
  1198     status change. A status change occurs when the file is created,
       
  1199     but it also occurs whenever the user writes or sets inode
       
  1200     information (for example, changing the file permissions).
       
  1201 
       
  1202     If neither creation time nor "last status change" time are not
       
  1203     available, returns the same as lastModified().
       
  1204 
       
  1205     \sa lastModified() lastRead()
       
  1206 */
       
  1207 
       
  1208 QDateTime QFileInfo::created() const
       
  1209 {
       
  1210     Q_D(const QFileInfo);
       
  1211     if(!d->data->fileEngine)
       
  1212         return QDateTime();
       
  1213     return d->getFileTime(QAbstractFileEngine::CreationTime);
       
  1214 }
       
  1215 
       
  1216 /*!
       
  1217     Returns the date and time when the file was last modified.
       
  1218 
       
  1219     \sa created() lastRead()
       
  1220 */
       
  1221 
       
  1222 QDateTime QFileInfo::lastModified() const
       
  1223 {
       
  1224     Q_D(const QFileInfo);
       
  1225     if(!d->data->fileEngine)
       
  1226         return QDateTime();
       
  1227     return d->getFileTime(QAbstractFileEngine::ModificationTime);
       
  1228 }
       
  1229 
       
  1230 /*!
       
  1231     Returns the date and time when the file was last read (accessed).
       
  1232 
       
  1233     On platforms where this information is not available, returns the
       
  1234     same as lastModified().
       
  1235 
       
  1236     \sa created() lastModified()
       
  1237 */
       
  1238 
       
  1239 QDateTime QFileInfo::lastRead() const
       
  1240 {
       
  1241     Q_D(const QFileInfo);
       
  1242     if(!d->data->fileEngine)
       
  1243         return QDateTime();
       
  1244     return d->getFileTime(QAbstractFileEngine::AccessTime);
       
  1245 }
       
  1246 
       
  1247 /*! \internal
       
  1248     Detaches all internal data.
       
  1249 */
       
  1250 
       
  1251 void QFileInfo::detach()
       
  1252 {
       
  1253     Q_D(QFileInfo);
       
  1254     d->detach();
       
  1255 }
       
  1256 
       
  1257 /*!
       
  1258     Returns true if caching is enabled; otherwise returns false.
       
  1259 
       
  1260     \sa setCaching(), refresh()
       
  1261 */
       
  1262 
       
  1263 bool QFileInfo::caching() const
       
  1264 {
       
  1265     Q_D(const QFileInfo);
       
  1266     return d->data->cache_enabled;
       
  1267 }
       
  1268 
       
  1269 /*!
       
  1270     If \a enable is true, enables caching of file information. If \a
       
  1271     enable is false caching is disabled.
       
  1272 
       
  1273     When caching is enabled, QFileInfo reads the file information from
       
  1274     the file system the first time it's needed, but generally not
       
  1275     later.
       
  1276 
       
  1277     Caching is enabled by default.
       
  1278 
       
  1279     \sa refresh(), caching()
       
  1280 */
       
  1281 
       
  1282 void QFileInfo::setCaching(bool enable)
       
  1283 {
       
  1284     Q_D(QFileInfo);
       
  1285     detach();
       
  1286     d->data->cache_enabled = enable;
       
  1287 }
       
  1288 
       
  1289 /*!
       
  1290     \fn QString QFileInfo::baseName(bool complete)
       
  1291 
       
  1292     Use completeBaseName() or the baseName() overload that takes no
       
  1293     parameters instead.
       
  1294 */
       
  1295 
       
  1296 /*!
       
  1297     \fn QString QFileInfo::extension(bool complete = true) const
       
  1298 
       
  1299     Use completeSuffix() or suffix() instead.
       
  1300 */
       
  1301 
       
  1302 /*!
       
  1303     \fn QString QFileInfo::absFilePath() const
       
  1304 
       
  1305     Use absoluteFilePath() instead.
       
  1306 */
       
  1307 
       
  1308 /*!
       
  1309     \fn QString QFileInfo::dirPath(bool absPath) const
       
  1310 
       
  1311     Use absolutePath() if the absolute path is wanted (\a absPath
       
  1312     is true) or path() if it's not necessary (\a absPath is false).
       
  1313 */
       
  1314 
       
  1315 /*!
       
  1316     \fn bool QFileInfo::convertToAbs()
       
  1317 
       
  1318     Use makeAbsolute() instead.
       
  1319 */
       
  1320 
       
  1321 /*!
       
  1322     \enum QFileInfo::Permission
       
  1323 
       
  1324     \compat
       
  1325 
       
  1326     \value ReadOwner
       
  1327     \value WriteOwner
       
  1328     \value ExeOwner
       
  1329     \value ReadUser
       
  1330     \value WriteUser
       
  1331     \value ExeUser
       
  1332     \value ReadGroup
       
  1333     \value WriteGroup
       
  1334     \value ExeGroup
       
  1335     \value ReadOther
       
  1336     \value WriteOther
       
  1337     \value ExeOther
       
  1338 */
       
  1339 
       
  1340 /*!
       
  1341     \fn bool QFileInfo::permission(PermissionSpec permissions) const
       
  1342     \compat
       
  1343 
       
  1344     Use permission() instead.
       
  1345 */
       
  1346 
       
  1347 /*!
       
  1348     \typedef QFileInfoList
       
  1349     \relates QFileInfo
       
  1350 
       
  1351     Synonym for QList<QFileInfo>.
       
  1352 */
       
  1353 
       
  1354 QT_END_NAMESPACE