Qt 4.8
Public Functions | Protected Variables | Private Functions | Friends | Related Functions | List of all members
QFileInfo Class Reference

The QFileInfo class provides system-independent file information. More...

#include <qfileinfo.h>

Public Functions

QDir absoluteDir () const
 Returns the file's absolute path as a QDir object. More...
 
QString absoluteFilePath () const
 Returns an absolute path including the file name. More...
 
QString absolutePath () const
 Returns a file's path absolute path. More...
 
QString baseName () const
 Returns the base name of the file without the path. More...
 
QString bundleName () const
 Returns the name of the bundle. More...
 
bool caching () const
 Returns true if caching is enabled; otherwise returns false. More...
 
QString canonicalFilePath () const
 Returns the canonical path including the file name, i.e. More...
 
QString canonicalPath () const
 Returns the file's path canonical path (excluding the file name), i.e. More...
 
QString completeBaseName () const
 Returns the complete base name of the file without the path. More...
 
QString completeSuffix () const
 Returns the complete suffix of the file. More...
 
QDateTime created () const
 Returns the date and time when the file was created. More...
 
void detach ()
 Detaches all internal data. More...
 
QDir dir () const
 Returns the path of the object's parent directory as a QDir object. More...
 
bool exists () const
 Returns true if the file exists; otherwise returns false. More...
 
QString fileName () const
 Returns the name of the file, excluding the path. More...
 
QString filePath () const
 Returns the file name, including the path (which may be absolute or relative). More...
 
QString group () const
 Returns the group of the file. More...
 
uint groupId () const
 Returns the id of the group the file belongs to. More...
 
bool isAbsolute () const
 Returns true if the file path name is absolute, otherwise returns false if the path is relative. More...
 
bool isBundle () const
 Returns true if this object points to a bundle or to a symbolic link to a bundle on Mac OS X; otherwise returns false. More...
 
bool isDir () const
 Returns true if this object points to a directory or to a symbolic link to a directory; otherwise returns false. More...
 
bool isExecutable () const
 Returns true if the file is executable; otherwise returns false. More...
 
bool isFile () const
 Returns true if this object points to a file or to a symbolic link to a file. More...
 
bool isHidden () const
 Returns true if this is a `hidden' file; otherwise returns false. More...
 
bool isReadable () const
 Returns true if the user can read the file; otherwise returns false. More...
 
bool isRelative () const
 Returns true if the file path name is relative, otherwise returns false if the path is absolute (e.g. More...
 
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. More...
 
bool isSymLink () const
 Returns true if this object points to a symbolic link (or to a shortcut on Windows); otherwise returns false. More...
 
bool isWritable () const
 Returns true if the user can write to the file; otherwise returns false. More...
 
QDateTime lastModified () const
 Returns the date and time when the file was last modified. More...
 
QDateTime lastRead () const
 Returns the date and time when the file was last read (accessed). More...
 
bool makeAbsolute ()
 Converts the file's path to an absolute path if it is not already in that form. More...
 
bool operator!= (const QFileInfo &fileinfo)
 Returns true if this QFileInfo object refers to a different file than the one specified by fileinfo; otherwise returns false. More...
 
bool operator!= (const QFileInfo &fileinfo) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QFileInfooperator= (const QFileInfo &fileinfo)
 Makes a copy of the given fileinfo and assigns it to this QFileInfo. More...
 
bool operator== (const QFileInfo &fileinfo)
 Returns true if this QFileInfo object refers to a file in the same location as fileinfo; otherwise returns false. More...
 
bool operator== (const QFileInfo &fileinfo) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QString owner () const
 Returns the owner of the file. More...
 
uint ownerId () const
 Returns the id of the owner of the file. More...
 
QString path () const
 Returns the file's path. More...
 
bool permission (QFile::Permissions permissions) const
 Tests for file permissions. More...
 
QFile::Permissions permissions () const
 Returns the complete OR-ed together combination of QFile::Permissions for the file. More...
 
 QFileInfo (QFileInfoPrivate *d)
 
 QFileInfo ()
 Constructs an empty QFileInfo object. More...
 
 QFileInfo (const QString &file)
 Constructs a new QFileInfo that gives information about the given file. More...
 
 QFileInfo (const QFile &file)
 Constructs a new QFileInfo that gives information about file file. More...
 
 QFileInfo (const QDir &dir, const QString &file)
 Constructs a new QFileInfo that gives information about the given file in the directory dir. More...
 
 QFileInfo (const QFileInfo &fileinfo)
 Constructs a new QFileInfo that is a copy of the given fileinfo. More...
 
QString readLink () const
 Use symLinkTarget() instead. More...
 
void refresh ()
 Refreshes the information about the file, i.e. More...
 
void setCaching (bool on)
 If enable is true, enables caching of file information. More...
 
void setFile (const QString &file)
 Sets the file that the QFileInfo provides information about to file. More...
 
void setFile (const QFile &file)
 Sets the file that the QFileInfo provides information about to file. More...
 
void setFile (const QDir &dir, const QString &file)
 Sets the file that the QFileInfo provides information about to file in directory dir. More...
 
qint64 size () const
 Returns the file size in bytes. More...
 
QString suffix () const
 Returns the suffix of the file. More...
 
QString symLinkTarget () const
 Returns the absolute path to the file or directory a symlink (or shortcut on Windows) points to, or a an empty string if the object isn't a symbolic link. More...
 
 ~QFileInfo ()
 Destroys the QFileInfo and frees its resources. More...
 

Protected Variables

QSharedDataPointer< QFileInfoPrivated_ptr
 

Private Functions

QFileInfoPrivated_func ()
 
const QFileInfoPrivated_func () const
 

Friends

class QDirIteratorPrivate
 

Related Functions

(Note that these are not member functions.)

 QFileInfoList
 Synonym for QList<QFileInfo>. More...
 

Detailed Description

The QFileInfo class provides system-independent file information.

Note
This class or function is reentrant.

QFileInfo provides information about a file's name and position (path) in the file system, its access rights and whether it is a directory or symbolic link, etc. The file's size and last modified/read times are also available. QFileInfo can also be used to obtain information about a Qt resource system{resource}.

A QFileInfo can point to a file with either a relative or an absolute file path. Absolute file paths begin with the directory separator "/" (or with a drive specification on Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current working directory. An example of an absolute path is the string "/tmp/quartz". A relative path might look like "src/fatlib". You can use the function isRelative() to check whether a QFileInfo is using a relative or an absolute file path. You can call the function makeAbsolute() to convert a relative QFileInfo's path to an absolute path.

The file that the QFileInfo works on is set in the constructor or later with setFile(). Use exists() to see if the file exists and size() to get its size.

The file's type is obtained with isFile(), isDir() and isSymLink(). The symLinkTarget() function provides the name of the file the symlink points to.

On Unix (including Mac OS X), the symlink has the same size() has the file it points to, because Unix handles symlinks transparently; similarly, opening a symlink using QFile effectively opens the link's target. For example:

#ifdef Q_OS_UNIX
QFileInfo info1("/home/bob/bin/untabify");
info1.isSymLink(); // returns true
info1.absoluteFilePath(); // returns "/home/bob/bin/untabify"
info1.size(); // returns 56201
info1.symLinkTarget(); // returns "/opt/pretty++/bin/untabify"
QFileInfo info2(info1.symLinkTarget());
info2.isSymLink(); // returns false
info2.absoluteFilePath(); // returns "/opt/pretty++/bin/untabify"
info2.size(); // returns 56201
#endif

On Windows, symlinks (shortcuts) are .lnk files. The reported size() is that of the symlink (not the link's target), and opening a symlink using QFile opens the .lnk file. For example:

#ifdef Q_OS_WIN
QFileInfo info1("C:\\Documents and Settings\\Bob\\untabify.lnk");
info1.isSymLink(); // returns true
info1.absoluteFilePath(); // returns "C:/Documents and Settings/Bob/untabify.lnk"
info1.size(); // returns 743
info1.symLinkTarget(); // returns "C:/Pretty++/untabify"
QFileInfo info2(info1.symLinkTarget());
info2.isSymLink(); // returns false
info2.absoluteFilePath(); // returns "C:/Pretty++/untabify"
info2.size(); // returns 63942
#endif

Elements of the file's name can be extracted with path() and fileName(). The fileName()'s parts can be extracted with baseName(), suffix() or completeSuffix(). QFileInfo objects to directories created by Qt classes will not have a trailing file separator. If you wish to use trailing separators in your own file info objects, just append one to the file name given to the constructors or setFile().

The file's dates are returned by created(), lastModified() and lastRead(). Information about the file's access permissions is obtained with isReadable(), isWritable() and isExecutable(). The file's ownership is available from owner(), ownerId(), group() and groupId(). You can examine a file's permissions and ownership in a single statement using the permission() function.

Performance Issues

Some of QFileInfo's functions query the file system, but for performance reasons, some functions only operate on the file name itself. For example: To return the absolute path of a relative file name, absolutePath() has to query the file system. The path() function, however, can work on the file name directly, and so it is faster.

Note
To speed up performance, QFileInfo caches information about the file.

To speed up performance, QFileInfo caches information about the file. Because files can be changed by other users or programs, or even by other parts of the same program, there is a function that refreshes the file information: refresh(). If you want to switch off a QFileInfo's caching and force it to access the file system every time you request information from it call setCaching(false).

See also
QDir, QFile

Definition at line 60 of file qfileinfo.h.

Constructors and Destructors

◆ QFileInfo() [1/6]

QFileInfo::QFileInfo ( QFileInfoPrivate p)
explicit
Warning
This function is not part of the public interface.

Definition at line 299 of file qfileinfo.cpp.

299  : d_ptr(p)
300 {
301 }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177

◆ QFileInfo() [2/6]

QFileInfo::QFileInfo ( )

Constructs an empty QFileInfo object.

Note that an empty QFileInfo object contain no file reference.

See also
setFile()

Definition at line 310 of file qfileinfo.cpp.

Referenced by setFile().

310  : d_ptr(new QFileInfoPrivate())
311 {
312 }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177

◆ QFileInfo() [3/6]

QFileInfo::QFileInfo ( const QString file)

Constructs a new QFileInfo that gives information about the given file.

The file can also include an absolute or relative path.

See also
setFile(), isRelative(), QDir::setCurrent(), QDir::isRelativePath()

Definition at line 320 of file qfileinfo.cpp.

320  : d_ptr(new QFileInfoPrivate(file))
321 {
322 }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177

◆ QFileInfo() [4/6]

QFileInfo::QFileInfo ( const QFile file)

Constructs a new QFileInfo that gives information about file file.

If the file has a relative path, the QFileInfo will also have a relative path.

See also
isRelative()

Definition at line 333 of file qfileinfo.cpp.

333  : d_ptr(new QFileInfoPrivate(file.fileName()))
334 {
335 }
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
Definition: qfile.cpp:470
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177

◆ QFileInfo() [5/6]

QFileInfo::QFileInfo ( const QDir dir,
const QString file 
)

Constructs a new QFileInfo that gives information about the given file in the directory dir.

If dir has a relative path, the QFileInfo will also have a relative path.

If file is an absolute path, then the directory specified by dir will be disregarded.

See also
isRelative()

Definition at line 349 of file qfileinfo.cpp.

350  : d_ptr(new QFileInfoPrivate(dir.filePath(file)))
351 {
352 }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177
QString filePath(const QString &fileName) const
Returns the path name of a file in the directory.
Definition: qdir.cpp:678

◆ QFileInfo() [6/6]

QFileInfo::QFileInfo ( const QFileInfo fileinfo)

Constructs a new QFileInfo that is a copy of the given fileinfo.

Definition at line 357 of file qfileinfo.cpp.

358  : d_ptr(fileinfo.d_ptr)
359 {
360 
361 }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177

◆ ~QFileInfo()

QFileInfo::~QFileInfo ( )

Destroys the QFileInfo and frees its resources.

Definition at line 367 of file qfileinfo.cpp.

368 {
369 }

Functions

◆ absoluteDir()

QDir QFileInfo::absoluteDir ( ) const

Returns the file's absolute path as a QDir object.

See also
dir(), filePath(), fileName(), isRelative()

Definition at line 873 of file qfileinfo.cpp.

Referenced by QPollingFileSystemWatcherEngine::FileInfo::FileInfo(), QPollingFileSystemWatcherEngine::FileInfo::operator!=(), and QFileDialog::selectFile().

874 {
875  return QDir(absolutePath());
876 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QString absolutePath() const
Returns a file&#39;s path absolute path.
Definition: qfileinfo.cpp:577

◆ absoluteFilePath()

QString QFileInfo::absoluteFilePath ( ) const

Returns an absolute path including the file name.

The absolute path name consists of the full path and the file name. On Unix this will always begin with the root, '/', directory. On Windows this will always begin 'D:/' where D is a drive letter, except for network shares that are not mapped to a drive letter, in which case the path will begin '//sharename/'. QFileInfo will uppercase drive letters. Note that QDir does not do this. The code snippet below shows this.

QFileInfo fi("c:/temp/foo"); => fi.absoluteFilePath() => "C:/temp/foo"

This function returns the same as filePath(), unless isRelative() is true. In contrast to canonicalFilePath(), symbolic links or redundant "." or ".." elements are not necessarily removed.

If the QFileInfo is empty it returns QDir::currentPath().

See also
filePath(), canonicalFilePath(), isRelative()

Definition at line 534 of file qfileinfo.cpp.

Referenced by _qt_get_directory(), QDeclarativeTypeLoader::absoluteFilePath(), QFileDialog::accept(), QSvgIconEngine::addFile(), QPixmapIconEngine::addFile(), QCoreApplication::applicationFilePath(), QDir::cd(), QDirModelPrivate::children(), QFontEngineQPF::cleanUpAfterClientCrash(), QWSSoundServerPrivate::feedDevice(), QDirModel::fileName(), QDirModel::filePath(), QConfFile::fromName(), QGtkStylePrivate::getFilesystemIcon(), QFileInfoGatherer::getInfo(), QFileIconProvider::icon(), QDeclarativeImportDatabase::importPlugin(), QDirModel::index(), QExtendedInformation::isCaseSensitive(), QFile::link(), QTranslator::load(), QPixmap::load(), makeAbsolute(), QDirModel::mkdir(), QDirModelPrivate::name(), QSvgHandler::processingInstruction(), QDeclarative_isFileCaseCorrect(), qt_create_commandline(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), registerFont(), QDirModel::remove(), QDirModelPrivate::resolvedInfo(), QDeclarativeImportDatabase::resolvePlugin(), QDirModel::rmdir(), QPluginLoader::setFileName(), QProcessPrivate::startProcess(), and QFileInfoGatherer::translateDriveName().

535 {
536  Q_D(const QFileInfo);
537  if (d->isDefaultConstructed)
538  return QLatin1String("");
539  return d->getFileName(QAbstractFileEngine::AbsoluteName);
540 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ absolutePath()

QString QFileInfo::absolutePath ( ) const

Returns a file's path absolute path.

This doesn't include the file name.

On Unix the absolute path will always begin with the root, '/', directory. On Windows this will always begin 'D:/' where D is a drive letter, except for network shares that are not mapped to a drive letter, in which case the path will begin '//sharename/'.

In contrast to canonicalPath() symbolic links or redundant "." or ".." elements are not necessarily removed.

Warning
If the QFileInfo object was created with an empty QString, the behavior of this function is undefined.
See also
absoluteFilePath(), path(), canonicalPath(), fileName(), isRelative()

Definition at line 577 of file qfileinfo.cpp.

Referenced by _qt_get_directory(), absoluteDir(), dlIterateCallback(), QZipReader::extractAll(), QCss::Parser::init(), QUrl::isParentOf(), QConfFile::isWritable(), QLibraryInfo::location(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), QDirModelPrivate::resolvedInfo(), QAxFactory::serverDirPath(), QPluginLoader::setFileName(), QGtkStylePrivate::setupGtkFileChooser(), and QFileSystemEngine::slowCanonicalized().

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 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ baseName()

QString QFileInfo::baseName ( ) const

Returns the base name of the file without the path.

Use completeBaseName() or the baseName() overload that takes no parameters instead.

The base name consists of all characters in the file up to (but not including) the first '.' character.

Example:

QFileInfo fi("/tmp/archive.tar.gz");
QString base = fi.baseName(); // base = "archive"

The base name of a file is computed equally on all platforms, independent of file naming conventions (e.g., ".bashrc" on Unix has an empty base name, and the suffix is "bashrc").

See also
fileName(), suffix(), completeSuffix(), completeBaseName()

Definition at line 773 of file qfileinfo.cpp.

Referenced by QCoreApplicationPrivate::appName(), and QScriptEnginePrivate::translationContextFromUrl().

774 {
775  Q_D(const QFileInfo);
776  if (d->isDefaultConstructed)
777  return QLatin1String("");
778  return d->fileEntry.baseName();
779 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ bundleName()

QString QFileInfo::bundleName ( ) const

Returns the name of the bundle.

Since
4.3

On Mac OS X this returns the proper localized name for a bundle if the path isBundle(). On all other platforms an empty QString is returned.

Example:

QFileInfo fi("/Applications/Safari.app");
QString bundle = fi.bundleName(); // name = "Safari"
See also
isBundle(), filePath(), baseName(), extension()

Definition at line 749 of file qfileinfo.cpp.

750 {
751  Q_D(const QFileInfo);
752  if (d->isDefaultConstructed)
753  return QLatin1String("");
754  return d->getFileName(QAbstractFileEngine::BundleName);
755 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ caching()

bool QFileInfo::caching ( ) const

Returns true if caching is enabled; otherwise returns false.

See also
setCaching(), refresh()

Definition at line 1346 of file qfileinfo.cpp.

Referenced by setFile().

1347 {
1348  Q_D(const QFileInfo);
1349  return d->cache_enabled;
1350 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ canonicalFilePath()

QString QFileInfo::canonicalFilePath ( ) const

Returns the canonical path including the file name, i.e.

an absolute path without symbolic links or redundant "." or ".." elements.

If the file does not exist, canonicalFilePath() returns an empty string.

See also
filePath(), absoluteFilePath(), dir()

Definition at line 551 of file qfileinfo.cpp.

Referenced by QFileDialogPrivate::_q_updateOkButton(), QFSEventsFileSystemWatcherEngine::addPaths(), QCoreApplication::applicationFilePath(), QScriptEngine::availableExtensions(), QDirIteratorPrivate::checkAndPushDirectory(), QFileSystemModel::filePath(), QFileInfoGatherer::getInfo(), QFileIconProviderPrivate::getWinIcon(), QScriptEngine::importExtension(), QTranslator::load(), operator==(), QDirIteratorPrivate::pushDirectory(), QDeclarative_isFileCaseCorrect(), QFSEventsFileSystemWatcherEngine::removePaths(), QPluginLoader::setFileName(), and QSslSocketPrivate::systemCaCertificates().

552 {
553  Q_D(const QFileInfo);
554  if (d->isDefaultConstructed)
555  return QLatin1String("");
556  return d->getFileName(QAbstractFileEngine::CanonicalName);
557 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ canonicalPath()

QString QFileInfo::canonicalPath ( ) const

Returns the file's path canonical path (excluding the file name), i.e.

an absolute path without symbolic links or redundant "." or ".." elements.

If the file does not exist, canonicalPath() returns an empty string.

See also
path(), absolutePath()

Definition at line 598 of file qfileinfo.cpp.

Referenced by QDnotifyFileSystemWatcherEngine::addPaths(), QFSEventsFileSystemWatcherEngine::addPaths(), and QFSEventsFileSystemWatcherEngine::removePaths().

599 {
600  Q_D(const QFileInfo);
601  if (d->isDefaultConstructed)
602  return QLatin1String("");
603  return d->getFileName(QAbstractFileEngine::CanonicalPathName);
604 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ completeBaseName()

QString QFileInfo::completeBaseName ( ) const

Returns the complete base name of the file without the path.

The complete base name consists of all characters in the file up to (but not including) the last '.' character.

Example:

QFileInfo fi("/tmp/archive.tar.gz");
QString base = fi.completeBaseName(); // base = "archive.tar"
See also
fileName(), suffix(), completeSuffix(), baseName()

Definition at line 792 of file qfileinfo.cpp.

Referenced by QFileDialogPrivate::qt_mac_filedialog_event_proc().

793 {
794  Q_D(const QFileInfo);
795  if (d->isDefaultConstructed)
796  return QLatin1String("");
797  return d->fileEntry.completeBaseName();
798 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ completeSuffix()

QString QFileInfo::completeSuffix ( ) const

Returns the complete suffix of the file.

The complete suffix consists of all characters in the file after (but not including) the first '.'.

Example:

QFileInfo fi("/tmp/archive.tar.gz");
QString ext = fi.completeSuffix(); // ext = "tar.gz"
See also
fileName(), suffix(), baseName(), completeBaseName()

Definition at line 811 of file qfileinfo.cpp.

Referenced by QLibrary::isLibrary(), QPixmap::load(), and loadOpenSslWin32().

812 {
813  Q_D(const QFileInfo);
814  if (d->isDefaultConstructed)
815  return QLatin1String("");
816  return d->fileEntry.completeSuffix();
817 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ created()

QDateTime QFileInfo::created ( ) const

Returns the date and time when the file was created.

On most Unix systems, this function returns the time of the last status change. A status change occurs when the file is created, but it also occurs whenever the user writes or sets inode information (for example, changing the file permissions).

If neither creation time nor "last status change" time are not available, returns the same as lastModified().

See also
lastModified() lastRead()

Definition at line 1278 of file qfileinfo.cpp.

Referenced by QNetworkDiskCache::expire(), and qt_CoCreateGuid().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ d_func() [1/2]

QFileInfoPrivate* QFileInfo::d_func ( )
inlineprivate

Definition at line 179 of file qfileinfo.h.

180  {
181  detach();
182  return const_cast<QFileInfoPrivate *>(d_ptr.constData());
183  }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177
const T * constData() const
Returns a const pointer to the shared data object.
Definition: qshareddata.h:84
void detach()
Detaches all internal data.
Definition: qfileinfo.cpp:1336

◆ d_func() [2/2]

const QFileInfoPrivate* QFileInfo::d_func ( ) const
inlineprivate

Definition at line 185 of file qfileinfo.h.

186  {
187  return d_ptr.constData();
188  }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177
const T * constData() const
Returns a const pointer to the shared data object.
Definition: qshareddata.h:84

◆ detach()

void QFileInfo::detach ( )

Detaches all internal data.

Warning
This function is not part of the public interface.

Definition at line 1336 of file qfileinfo.cpp.

1337 {
1338  d_ptr.detach();
1339 }
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
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177

◆ dir()

QDir QFileInfo::dir ( ) const

Returns the path of the object's parent directory as a QDir object.

Note: The QDir returned always corresponds to the object's parent directory, even if the QFileInfo represents a directory.

For each of the following, dir() returns a QDir for "~/examples/191697".

QFileInfo fileInfo1("~/examples/191697/.");
QFileInfo fileInfo2("~/examples/191697/..");
QFileInfo fileInfo3("~/examples/191697/main.cpp");

For each of the following, dir() returns a QDir for ".".

QFileInfo fileInfo4(".");
QFileInfo fileInfo5("..");
QFileInfo fileInfo6("main.cpp");
See also
absolutePath(), filePath(), fileName(), isRelative(), absoluteDir()

Definition at line 861 of file qfileinfo.cpp.

Referenced by absoluteDir(), QDeclarativeImportsPrivate::importExtension(), QDirModel::remove(), QDirModel::rmdir(), and QDirModel::setData().

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 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ exists()

bool QFileInfo::exists ( ) const

Returns true if the file exists; otherwise returns false.

Note
If the file is a symlink that points to a non existing file, false is returned.

Definition at line 675 of file qfileinfo.cpp.

Referenced by _qt_get_directory(), QFileDialog::accept(), QDnotifyFileSystemWatcherEngine::addPaths(), QFSEventsFileSystemWatcherEngine::addPaths(), QPollingFileSystemWatcherEngine::addPaths(), QmlApplicationViewerPrivate::adjustPath(), QCoreApplication::applicationFilePath(), QUnixPrintWidgetPrivate::checkFields(), QFile::exists(), QFileSystemModel::filePath(), QFileInfoGatherer::getInfo(), QDirModel::index(), QLibraryPrivate::isPlugin(), QConfFile::isWritable(), QPixmap::load(), QDirIteratorPrivate::matchesFilters(), QFileSystemModelPrivate::node(), QSvgHandler::processingInstruction(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), QDnotifyFileSystemWatcherEngine::refresh(), QDeclarativeImportDatabase::resolvePlugin(), resolveScheme(), QWidgetPrivate::setWindowTitle_sys(), QExtendedInformation::size(), QPollingFileSystemWatcherEngine::timeout(), and QExtendedInformation::type().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ fileName()

QString QFileInfo::fileName ( ) const

Returns the name of the file, excluding the path.

Example:

QFileInfo fi("/tmp/archive.tar.gz");
QString name = fi.fileName(); // name = "archive.tar.gz"

Note that, if this QFileInfo object is given a path ending in a slash, the name of the file is considered empty.

See also
isRelative(), filePath(), baseName(), extension()

Definition at line 726 of file qfileinfo.cpp.

Referenced by QFileDialogPrivate::_q_updateOkButton(), QFileDialog::accept(), QDirIteratorPrivate::checkAndPushDirectory(), QBenchmarkValgrindUtils::cleanup(), constructWindowTitleFromFilePath(), QFSFileEngineIterator::currentFileName(), QNetworkDiskCache::expire(), QFileInfoGatherer::fetch(), QDirIterator::fileName(), QDirModel::fileName(), QFileInfoGatherer::getFileInfos(), QBenchmarkValgrindUtils::getNewestFileName(), QDirModel::index(), QFileDialogPrivate::initialSelection(), QUrl::isParentOf(), QDeclarativeDebugServerPrivate::loadConnectionPlugin(), QScriptDebuggerConsolePrivate::loadScriptedCommands(), QDirModelPrivate::name(), QDirSortItemComparator::operator()(), QNSOpenSavePanelDelegate::panel:shouldShowFilename:, QFontEngineQPF::QFontEngineQPF(), qt_parseEtcLpMember(), qt_parseEtcLpPrinters(), qt_parseSpoolInterface(), qt_win_get_open_file_name(), qt_win_get_save_file_name(), QNetworkDiskCachePrivate::removeFile(), QNSOpenSavePanelDelegate::runApplicationModalPanel, QDirModel::setData(), QPluginLoader::setFileName(), QGtkStylePrivate::setupGtkFileChooser(), QDirPrivate::sortFileList(), and QFileInfoGatherer::translateDriveName().

727 {
728  Q_D(const QFileInfo);
729  if (d->isDefaultConstructed)
730  return QLatin1String("");
731  return d->fileEntry.fileName();
732 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ filePath()

QString QFileInfo::filePath ( ) const

Returns the file name, including the path (which may be absolute or relative).

See also
absoluteFilePath(), canonicalFilePath(), isRelative()

Definition at line 707 of file qfileinfo.cpp.

Referenced by QDnotifyFileSystemWatcherEngine::addPaths(), QCoreApplication::applicationFilePath(), QAbstractFileEngineIterator::currentFileInfo(), QDirIterator::filePath(), QFileSystemModel::filePath(), QFileInfoGatherer::getInfo(), QFileIconProviderPrivate::getWinIcon(), QUrl::isParentOf(), QDirIteratorPrivate::pushDirectory(), qt_parseSpoolInterface(), QNSOpenSavePanelDelegate::runApplicationModalPanel, and QFileDialogPrivate::selectFile_sys().

708 {
709  Q_D(const QFileInfo);
710  if (d->isDefaultConstructed)
711  return QLatin1String("");
712  return d->fileEntry.filePath();
713 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ group()

QString QFileInfo::group ( ) const

Returns the group of the file.

On Windows, on systems where files do not have groups, or if an error occurs, an empty string is returned.

This function can be time consuming under Unix (in the order of milliseconds).

See also
groupId(), owner(), ownerId()

Definition at line 1167 of file qfileinfo.cpp.

1168 {
1169  Q_D(const QFileInfo);
1170  if (d->isDefaultConstructed)
1171  return QLatin1String("");
1172  return d->getFileOwner(QAbstractFileEngine::OwnerGroup);
1173 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ groupId()

uint QFileInfo::groupId ( ) const

Returns the id of the group the file belongs to.

On Windows and on systems where files do not have groups this function always returns (uint) -2.

See also
group(), owner(), ownerId()

Definition at line 1183 of file qfileinfo.cpp.

Referenced by QPollingFileSystemWatcherEngine::FileInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), and QDnotifyFileSystemWatcherEngine::Directory::File::updateInfo().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isAbsolute()

bool QFileInfo::isAbsolute ( ) const
inline

Returns true if the file path name is absolute, otherwise returns false if the path is relative.

See also
isRelative()

Definition at line 111 of file qfileinfo.h.

Referenced by QUrl::isParentOf(), and QFileDialog::selectFile().

111 { return !isRelative(); }
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

◆ isBundle()

bool QFileInfo::isBundle ( ) const

Returns true if this object points to a bundle or to a symbolic link to a bundle on Mac OS X; otherwise returns false.

Since
4.3
See also
isDir(), isSymLink(), isFile()

Definition at line 1014 of file qfileinfo.cpp.

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isDir()

bool QFileInfo::isDir ( ) const

Returns true if this object points to a directory or to a symbolic link to a directory; otherwise returns false.

See also
isFile(), isSymLink(), isBundle()

Definition at line 990 of file qfileinfo.cpp.

Referenced by QCompleterPrivate::_q_complete(), QFileDialogPrivate::_q_updateOkButton(), _qt_get_directory(), QFileDialog::accept(), QInotifyFileSystemWatcherEngine::addPaths(), QDnotifyFileSystemWatcherEngine::addPaths(), QWindowsFileSystemWatcherEngine::addPaths(), QFSEventsFileSystemWatcherEngine::addPaths(), QPollingFileSystemWatcherEngine::addPaths(), QCoreApplication::applicationFilePath(), QDirIteratorPrivate::checkAndPushDirectory(), QUnixPrintWidgetPrivate::checkFields(), QDirModelPrivate::children(), QPollingFileSystemWatcherEngine::FileInfo::FileInfo(), QDirModel::flags(), QFileIconProviderPrivate::getWinIcon(), QDirModel::hasChildren(), QFileIconProvider::icon(), QFileDialogPrivate::initialSelection(), QFileSystemModel::isDir(), QNetworkAccessFileBackend::loadFileInfo(), QDirIteratorPrivate::matchesFilters(), QDirModelPrivate::node(), QPollingFileSystemWatcherEngine::FileInfo::operator!=(), QDirSortItemComparator::operator()(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), qt_getLprPrinters(), qt_parseEtcLpPrinters(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), QDirModel::remove(), QDirModel::rmdir(), QDirModel::rowCount(), QGtkStylePrivate::setupGtkFileChooser(), QDirModelPrivate::size(), QFileSystemEngine::slowCanonicalized(), QProcessPrivate::startProcess(), QFileIconProvider::type(), and QExtendedInformation::type().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isExecutable()

bool QFileInfo::isExecutable ( ) const

Returns true if the file is executable; otherwise returns false.

See also
isReadable(), isWritable(), permission()

Definition at line 932 of file qfileinfo.cpp.

Referenced by QFileIconProviderPrivate::getWinIcon(), and QDirIteratorPrivate::matchesFilters().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isFile()

bool QFileInfo::isFile ( ) const

Returns true if this object points to a file or to a symbolic link to a file.

Returns false if the object points to something which isn't a file, such as a directory.

See also
isDir(), isSymLink(), isBundle()

Definition at line 971 of file qfileinfo.cpp.

Referenced by QDeclarativeTypeLoader::absoluteFilePath(), find_translation(), QFileIconProviderPrivate::getWinIcon(), QFileIconProvider::icon(), isCacheable(), QTranslator::load(), QDirIteratorPrivate::matchesFilters(), qt_getLprPrinters(), qt_parseEtcLpMember(), qt_parseSpoolInterface(), QFileIconProvider::type(), and QExtendedInformation::type().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isHidden()

bool QFileInfo::isHidden ( ) const

Returns true if this is a `hidden' file; otherwise returns false.

Note: This function returns true for the special entries "." and ".." on Unix, even though QDir::entryList threats them as shown.

Definition at line 951 of file qfileinfo.cpp.

Referenced by QDirIteratorPrivate::checkAndPushDirectory(), QExtendedInformation::isHidden(), and QDirIteratorPrivate::matchesFilters().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isReadable()

bool QFileInfo::isReadable ( ) const

Returns true if the user can read the file; otherwise returns false.

See also
isWritable(), isExecutable(), permission()

Definition at line 896 of file qfileinfo.cpp.

Referenced by find_translation(), QFileInfoGatherer::getInfo(), QTranslator::load(), and QDirIteratorPrivate::matchesFilters().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isRelative()

bool QFileInfo::isRelative ( ) const

Returns true if the file path name is relative, otherwise returns false if the path is absolute (e.g.

under Unix a path is absolute if it begins with a "/").

See also
isAbsolute()

Definition at line 642 of file qfileinfo.cpp.

Referenced by QDir::isRelativePath().

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 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isRoot()

bool QFileInfo::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 at line 1062 of file qfileinfo.cpp.

Referenced by QDirModel::fileName(), QFileIconProviderPrivate::getWinIcon(), QFileIconProvider::icon(), QDirModel::index(), QDirModelPrivate::name(), and QFileIconProvider::type().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isSymLink()

bool QFileInfo::isSymLink ( ) const

Returns true if this object points to a symbolic link (or to a shortcut on Windows); otherwise returns false.

On Unix (including Mac OS X), opening a symlink effectively opens the link's target. On Windows, it opens the .lnk file itself.

Example:

if (info.isSymLink())
fileName = info.symLinkTarget();
Note
If the symlink points to a non existing file, exists() returns false.
See also
isFile(), isDir(), symLinkTarget()

Definition at line 1044 of file qfileinfo.cpp.

Referenced by QCoreApplication::applicationFilePath(), QDirIteratorPrivate::checkAndPushDirectory(), QDirModelPrivate::children(), QDirModel::fileName(), QDirModel::filePath(), QFileInfoGatherer::getInfo(), QFileIconProviderPrivate::getWinIcon(), QFileIconProvider::icon(), QExtendedInformation::isSymLink(), QDirIteratorPrivate::matchesFilters(), QDirIteratorPrivate::pushDirectory(), QDirModelPrivate::resolvedInfo(), runningUnderDebugger(), QExtendedInformation::size(), QFileSystemEngine::slowCanonicalized(), QFileIconProvider::type(), and QExtendedInformation::type().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ isWritable()

bool QFileInfo::isWritable ( ) const

Returns true if the user can write to the file; otherwise returns false.

See also
isReadable(), isExecutable(), permission()

Definition at line 914 of file qfileinfo.cpp.

Referenced by QUnixPrintWidgetPrivate::checkFields(), QDirModel::flags(), and QDirIteratorPrivate::matchesFilters().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ lastModified()

QDateTime QFileInfo::lastModified ( ) const

Returns the date and time when the file was last modified.

See also
created() lastRead()

Definition at line 1296 of file qfileinfo.cpp.

Referenced by QDnotifyFileSystemWatcherEngine::addPaths(), QMacPasteboardMimeVCard::convertFromMime(), QLibraryPrivate::isPlugin(), QExtendedInformation::lastModified(), QPixmap::load(), QNetworkAccessFileBackend::loadFileInfo(), QFontDatabasePrivate::loadFromCache(), QPollingFileSystemWatcherEngine::FileInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QDirSortItemComparator::operator()(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QConfFileSettingsPrivate::syncConfFile(), and QDnotifyFileSystemWatcherEngine::Directory::File::updateInfo().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ lastRead()

QDateTime QFileInfo::lastRead ( ) const

Returns the date and time when the file was last read (accessed).

On platforms where this information is not available, returns the same as lastModified().

See also
created() lastModified()

Definition at line 1317 of file qfileinfo.cpp.

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ makeAbsolute()

bool QFileInfo::makeAbsolute ( )

Converts the file's path to an absolute path if it is not already in that form.

Returns true to indicate that the path was converted; otherwise returns false to indicate that the path was already absolute.

See also
filePath(), isRelative()

Definition at line 659 of file qfileinfo.cpp.

Referenced by QGtkStylePrivate::setupGtkFileChooser().

660 {
663  return false;
664 
666  return true;
667 }
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
Definition: qfileinfo.cpp:468
const T * constData() const
Returns a const pointer to the shared data object.
Definition: qshareddata.h:84
bool isRelative() const
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151

◆ operator!=() [1/2]

bool QFileInfo::operator!= ( const QFileInfo fileinfo)
inline

Returns true if this QFileInfo object refers to a different file than the one specified by fileinfo; otherwise returns false.

See also
operator==()

Definition at line 80 of file qfileinfo.h.

80 { return !(operator==(fileinfo)); } // 5.0 - remove me
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

◆ operator!=() [2/2]

bool QFileInfo::operator!= ( const QFileInfo fileinfo) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 81 of file qfileinfo.h.

81 { return !(operator==(fileinfo)); }
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

◆ operator=()

QFileInfo & QFileInfo::operator= ( const QFileInfo fileinfo)

Makes a copy of the given fileinfo and assigns it to this QFileInfo.

Definition at line 447 of file qfileinfo.cpp.

448 {
449  d_ptr = fileinfo.d_ptr;
450  return *this;
451 }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177

◆ operator==() [1/2]

bool QFileInfo::operator== ( const QFileInfo fileinfo)

Returns true if this QFileInfo object refers to a file in the same location as fileinfo; otherwise returns false.

Note that the result of comparing two empty QFileInfo objects, containing no file references, is undefined.

Warning
This will not compare two different symbolic links pointing to the same file.
Long and short file names that refer to the same file on Windows are treated as if they referred to different files.
See also
operator!=()

Definition at line 439 of file qfileinfo.cpp.

440 {
441  return const_cast<const QFileInfo *>(this)->operator==(fileinfo);
442 }
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ operator==() [2/2]

bool QFileInfo::operator== ( const QFileInfo fileinfo) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 391 of file qfileinfo.cpp.

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 }
double d
Definition: qnumeric_p.h:62
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177
#define Q_D(Class)
Definition: qglobal.h:2482
virtual bool caseSensitive() const
Should return true if the underlying file system is case-sensitive; otherwise return false...
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
Definition: qfileinfo.cpp:551
CaseSensitivity
Definition: qnamespace.h:1451
int compare(const QString &s) const
Definition: qstring.cpp:5037
qint64 size() const
Returns the file size in bytes.
Definition: qfileinfo.cpp:1248
QString filePath() const
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ owner()

QString QFileInfo::owner ( ) const

Returns the owner of the file.

On systems where files do not have owners, or if an error occurs, an empty string is returned.

This function can be time consuming under Unix (in the order of milliseconds).

See also
ownerId(), group(), groupId()

Definition at line 1128 of file qfileinfo.cpp.

1129 {
1130  Q_D(const QFileInfo);
1131  if (d->isDefaultConstructed)
1132  return QLatin1String("");
1133  return d->getFileOwner(QAbstractFileEngine::OwnerUser);
1134 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ ownerId()

uint QFileInfo::ownerId ( ) const

Returns the id of the owner of the file.

On Windows and on systems where files do not have owners this function returns ((uint) -2).

See also
owner(), group(), groupId()

Definition at line 1144 of file qfileinfo.cpp.

Referenced by QPollingFileSystemWatcherEngine::FileInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), and QDnotifyFileSystemWatcherEngine::Directory::File::updateInfo().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ path()

QString QFileInfo::path ( ) const

Returns the file's path.

This doesn't include the file name.

Note that, if this QFileInfo object is given a path ending in a slash, the name of the file is considered empty and this function will return the entire path.

See also
filePath(), absolutePath(), canonicalPath(), dir(), fileName(), isRelative()

Definition at line 615 of file qfileinfo.cpp.

Referenced by QFileDialog::accept(), QCoreApplication::applicationDirPath(), QUrl::isParentOf(), QSystemLibrary::load(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), and qt_win_get_save_file_name().

616 {
617  Q_D(const QFileInfo);
618  if (d->isDefaultConstructed)
619  return QLatin1String("");
620  return d->fileEntry.path();
621 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ permission()

bool QFileInfo::permission ( QFile::Permissions  permissions) const

Tests for file permissions.

Use permission() instead.

The permissions argument can be several flags of type QFile::Permissions OR-ed together to check for permission combinations.

On systems where files do not have permissions this function always returns true.

Example:

QFileInfo fi("/tmp/archive.tar.gz");
if (fi.permission(QFile::WriteUser | QFile::ReadGroup))
qWarning("I can change the file; my group can read the file");
if (fi.permission(QFile::WriteGroup | QFile::WriteOther))
qWarning("The group or others can change the file");
See also
isReadable(), isWritable(), isExecutable()

Definition at line 1209 of file qfileinfo.cpp.

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.
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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
QFile::Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permissions for the file.
Definition: qfileinfo.cpp:1228
#define Q_D(Class)
Definition: qglobal.h:2482
unsigned int uint
Definition: qglobal.h:996
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ permissions()

QFile::Permissions QFileInfo::permissions ( ) const

Returns the complete OR-ed together combination of QFile::Permissions for the file.

Definition at line 1228 of file qfileinfo.cpp.

Referenced by QPollingFileSystemWatcherEngine::FileInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), permission(), QExtendedInformation::permissions(), and QDnotifyFileSystemWatcherEngine::Directory::File::updateInfo().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ readLink()

QString QFileInfo::readLink ( ) const

Use symLinkTarget() instead.

Definition at line 1110 of file qfileinfo.cpp.

Referenced by QFile::readLink().

1111 {
1112  Q_D(const QFileInfo);
1113  if (d->isDefaultConstructed)
1114  return QLatin1String("");
1115  return d->getFileName(QAbstractFileEngine::LinkName);
1116 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ refresh()

void QFileInfo::refresh ( )

Refreshes the information about the file, i.e.

reads in information from the file system the next time a cached property is fetched.

Note
On Windows CE, there might be a delay for the file system driver to detect changes on the file.

Definition at line 695 of file qfileinfo.cpp.

Referenced by QPollingFileSystemWatcherEngine::timeout().

696 {
697  Q_D(QFileInfo);
698  d->clear();
699 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ setCaching()

void QFileInfo::setCaching ( bool  enable)

If enable is true, enables caching of file information.

If enable is false caching is disabled.

When caching is enabled, QFileInfo reads the file information from the file system the first time it's needed, but generally not later.

Caching is enabled by default.

See also
refresh(), caching()

Definition at line 1364 of file qfileinfo.cpp.

Referenced by QDirModelPrivate::appendChild().

1365 {
1366  Q_D(QFileInfo);
1367  d->cache_enabled = enable;
1368 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ setFile() [1/3]

void QFileInfo::setFile ( const QString file)

Sets the file that the QFileInfo provides information about to file.

The file can also include an absolute or relative file path. Absolute paths begin with the directory separator (e.g. "/" under Unix) or a drive specification (under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory.

Example:

QString absolute = "/local/bin";
QString relative = "local/bin";
QFileInfo absFile(absolute);
QFileInfo relFile(relative);
// absFile and relFile now point to the same file
// absFile now points to "/local/bin",
// while relFile points to "/tmp/local/bin"
See also
isRelative(), QDir::setCurrent(), QDir::isRelativePath()

Definition at line 468 of file qfileinfo.cpp.

Referenced by _qt_get_directory(), QAbstractFileEngineIterator::currentFileInfo(), find_translation(), QFileInfoGatherer::getFileInfos(), QUrl::isParentOf(), QTranslator::load(), makeAbsolute(), qt_getLprPrinters(), qt_win_get_open_file_names(), QDirModelPrivate::resolvedInfo(), setFile(), QGtkStylePrivate::setupGtkFileChooser(), and QFileSystemEngine::slowCanonicalized().

469 {
471  *this = QFileInfo(file);
473 }
QSharedDataPointer< QFileInfoPrivate > d_ptr
Definition: qfileinfo.h:177
bool caching() const
Returns true if caching is enabled; otherwise returns false.
Definition: qfileinfo.cpp:1346
const T * constData() const
Returns a const pointer to the shared data object.
Definition: qshareddata.h:84
QFileInfo()
Constructs an empty QFileInfo object.
Definition: qfileinfo.cpp:310

◆ setFile() [2/3]

void QFileInfo::setFile ( const QFile file)

Sets the file that the QFileInfo provides information about to file.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If file includes a relative path, the QFileInfo will also have a relative path.

See also
isRelative()

Definition at line 489 of file qfileinfo.cpp.

490 {
491  setFile(file.fileName());
492 }
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
Definition: qfile.cpp:470
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
Definition: qfileinfo.cpp:468

◆ setFile() [3/3]

void QFileInfo::setFile ( const QDir dir,
const QString file 
)

Sets the file that the QFileInfo provides information about to file in directory dir.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If file includes a relative path, the QFileInfo will also have a relative path.

See also
isRelative()

Definition at line 508 of file qfileinfo.cpp.

509 {
510  setFile(dir.filePath(file));
511 }
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
Definition: qfileinfo.cpp:468
QString filePath(const QString &fileName) const
Returns the path name of a file in the directory.
Definition: qdir.cpp:678

◆ size()

qint64 QFileInfo::size ( ) const

Returns the file size in bytes.

If the file does not exist or cannot be fetched, 0 is returned.

See also
exists()

Definition at line 1248 of file qfileinfo.cpp.

Referenced by QNetworkDiskCache::expire(), QPixmap::load(), QNetworkAccessFileBackend::loadFileInfo(), QDirSortItemComparator::operator()(), operator==(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QNetworkDiskCachePrivate::removeFile(), QDirModelPrivate::size(), QExtendedInformation::size(), and QConfFileSettingsPrivate::syncConfFile().

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 }
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ suffix()

QString QFileInfo::suffix ( ) const

Returns the suffix of the file.

The suffix consists of all characters in the file after (but not including) the last '.'.

Example:

QFileInfo fi("/tmp/archive.tar.gz");
QString ext = fi.suffix(); // ext = "gz"

The suffix of a file is computed equally on all platforms, independent of file naming conventions (e.g., ".bashrc" on Unix has an empty base name, and the suffix is "bashrc").

See also
fileName(), completeSuffix(), baseName(), completeBaseName()

Definition at line 834 of file qfileinfo.cpp.

Referenced by QPrintPreviewDialogPrivate::_q_print(), QUnixPrintWidgetPrivate::_q_printerChanged(), QFileDialogPrivate::_q_useNameFilter(), QIcon::addFile(), QFileIconProviderPrivate::getWinIcon(), isCacheable(), QExtendedInformation::isSymLink(), QDirSortItemComparator::operator()(), QPluginLoader::setFileName(), QPrinter::setOutputFileName(), and QFileIconProvider::type().

835 {
836  Q_D(const QFileInfo);
837  if (d->isDefaultConstructed)
838  return QLatin1String("");
839  return d->fileEntry.suffix();
840 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ symLinkTarget()

QString QFileInfo::symLinkTarget ( ) const
inline

Returns the absolute path to the file or directory a symlink (or shortcut on Windows) points to, or a an empty string if the object isn't a symbolic link.

Since
4.2

This name may not represent an existing file; it is only a string. QFileInfo::exists() returns true if the symlink points to an existing file.

See also
exists(), isSymLink(), isDir(), isFile()

Definition at line 121 of file qfileinfo.h.

Referenced by QDirModelPrivate::children(), QFileInfoGatherer::getInfo(), QDirModelPrivate::resolvedInfo(), runningUnderDebugger(), and QFileSystemEngine::slowCanonicalized().

121 { return readLink(); }
QString readLink() const
Use symLinkTarget() instead.
Definition: qfileinfo.cpp:1110

Friends and Related Functions

◆ QDirIteratorPrivate

friend class QDirIteratorPrivate
friend

Definition at line 62 of file qfileinfo.h.

◆ QFileInfoList()

QFileInfoList
related

Synonym for QList<QFileInfo>.

Properties

◆ d_ptr

QSharedDataPointer<QFileInfoPrivate> QFileInfo::d_ptr
protected

The documentation for this class was generated from the following files: