![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore \reentrant More...
#include <qfileinfo.h>
Public Member Functions | |
QFileInfo (QFileInfoPrivate *d) | |
QFileInfo () | |
Constructs an empty QFileInfo object. | |
QFILEINFO_MAYBE_EXPLICIT | QFileInfo (const QString &file) |
Constructs a new QFileInfo that gives information about the given file. | |
QFILEINFO_MAYBE_EXPLICIT | QFileInfo (const QFileDevice &file) |
Constructs a new QFileInfo that gives information about file file. | |
QFILEINFO_MAYBE_EXPLICIT | QFileInfo (const QDir &dir, const QString &file) |
Constructs a new QFileInfo that gives information about the given file relative to the directory dir. | |
QFileInfo (const QFileInfo &fileinfo) | |
Constructs a new QFileInfo that is a copy of the given fileinfo. | |
~QFileInfo () | |
Destroys the QFileInfo and frees its resources. | |
QFileInfo & | operator= (const QFileInfo &fileinfo) |
Move-assigns other to this QFileInfo instance. | |
void | swap (QFileInfo &other) noexcept |
bool | operator== (const QFileInfo &fileinfo) const |
Returns true if this QFileInfo object refers to a file in the same location as fileinfo; otherwise returns false . | |
bool | operator!= (const QFileInfo &fileinfo) const |
Returns true if this QFileInfo object refers to a different file than the one specified by fileinfo; otherwise returns false . | |
void | setFile (const QString &file) |
Sets the file that the QFileInfo provides information about to file. | |
void | setFile (const QFileDevice &file) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the file that the QFileInfo provides information about to file. | |
void | setFile (const QDir &dir, const QString &file) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the file that the QFileInfo provides information about to file in directory dir. | |
bool | exists () const |
Returns true if the file exists; otherwise returns false . | |
void | refresh () |
Refreshes the information about the file, i.e. | |
QString | filePath () const |
Returns the file name, including the path (which may be absolute or relative). | |
QString | absoluteFilePath () const |
Returns an absolute path including the file name. | |
QString | canonicalFilePath () const |
Returns the canonical path including the file name, i.e. | |
QString | fileName () const |
Returns the name of the file, excluding the path. | |
QString | baseName () const |
Returns the base name of the file without the path. | |
QString | completeBaseName () const |
Returns the complete base name of the file without the path. | |
QString | suffix () const |
Returns the suffix (extension) of the file. | |
QString | bundleName () const |
QString | completeSuffix () const |
Returns the complete suffix (extension) of the file. | |
QString | path () const |
Returns the file's path. | |
QString | absolutePath () const |
Returns a file's path absolute path. | |
QString | canonicalPath () const |
Returns the file's path canonical path (excluding the file name), i.e. | |
QDir | dir () const |
Returns the path of the object's parent directory as a QDir object. | |
QDir | absoluteDir () const |
Returns the file's absolute path as a QDir object. | |
bool | isReadable () const |
Returns true if the user can read the file; otherwise returns false . | |
bool | isWritable () const |
Returns true if the user can write to the file; otherwise returns false . | |
bool | isExecutable () const |
Returns true if the file is executable; otherwise returns false . | |
bool | isHidden () const |
Returns true if this is a ‘hidden’ file; otherwise returns false . | |
bool | isNativePath () const |
bool | isRelative () const |
Returns true if the file path is relative, otherwise returns false (i.e. | |
bool | isAbsolute () const |
Returns true if the file path is absolute, otherwise returns false (i.e. | |
bool | makeAbsolute () |
Converts the file's path to an absolute path if it is not already in that form. | |
bool | isFile () const |
Returns true if this object points to a file or to a symbolic link to a file. | |
bool | isDir () const |
Returns true if this object points to a directory or to a symbolic link to a directory. | |
bool | isSymLink () const |
Returns true if this object points to a symbolic link, shortcut, or alias; otherwise returns false . | |
bool | isSymbolicLink () const |
Returns true if this object points to a symbolic link; otherwise returns false . | |
bool | isShortcut () const |
Returns true if this object points to a shortcut; otherwise returns false . | |
bool | isAlias () const |
Returns true if this object points to an alias; otherwise returns false . | |
bool | isJunction () const |
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 . | |
bool | isBundle () const |
QString | symLinkTarget () const |
QString | readSymLink () const |
QString | junctionTarget () const |
QString | owner () const |
Returns the owner of the file. | |
uint | ownerId () const |
Returns the id of the owner of the file. | |
QString | group () const |
Returns the group of the file. | |
uint | groupId () const |
Returns the id of the group the file belongs to. | |
bool | permission (QFile::Permissions permissions) const |
Tests for file permissions. | |
QFile::Permissions | permissions () const |
Returns the complete OR-ed together combination of QFile::Permissions for the file. | |
qint64 | size () const |
Returns the file size in bytes. | |
QDateTime | birthTime () const |
Returns the date and time when the file was created (born), in local time. | |
QDateTime | metadataChangeTime () const |
Returns the date and time when the file's metadata was last changed, in local time. | |
QDateTime | lastModified () const |
Returns the date and time when the file was last modified. | |
QDateTime | lastRead () const |
Returns the date and time when the file was last read (accessed). | |
QDateTime | fileTime (QFile::FileTime time) const |
QDateTime | birthTime (const QTimeZone &tz) const |
Returns the date and time when the file was created (born). | |
QDateTime | metadataChangeTime (const QTimeZone &tz) const |
Returns the date and time when the file's metadata was last changed. | |
QDateTime | lastModified (const QTimeZone &tz) const |
Returns the date and time when the file was last modified. | |
QDateTime | lastRead (const QTimeZone &tz) const |
Returns the date and time when the file was last read (accessed). | |
QDateTime | fileTime (QFile::FileTime time, const QTimeZone &tz) const |
bool | caching () const |
Returns true if caching is enabled; otherwise returns false . | |
void | setCaching (bool on) |
If enable is true, enables caching of file information. | |
void | stat () |
Reads all attributes from the file system. | |
Static Public Member Functions | |
static bool | exists (const QString &file) |
Protected Attributes | |
QSharedDataPointer< QFileInfoPrivate > | d_ptr |
Friends | |
class | QDirIteratorPrivate |
Related Symbols | |
(Note that these are not member symbols.) | |
QFileInfoList | |
Synonym for QList<QFileInfo>. | |
\inmodule QtCore \reentrant
The QFileInfo class provides system-independent file information.
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 \l{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.
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().
Date and time related information are returned by birthTime(), fileTime(), lastModified(), lastRead(), and metadataChangeTime(). Information about access permissions can be obtained with isReadable(), isWritable(), and isExecutable(). Ownership information can be obtained with owner(), ownerId(), group(), and groupId(). You can also examine permissions and ownership in a single statement using the permission() function.
Definition at line 21 of file qfileinfo.h.
|
explicit |
Definition at line 336 of file qfileinfo.cpp.
QFileInfo::QFileInfo | ( | ) |
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.
Definition at line 357 of file qfileinfo.cpp.
QFileInfo::QFileInfo | ( | const QFileDevice & | 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.
Definition at line 370 of file qfileinfo.cpp.
Constructs a new QFileInfo that gives information about the given file relative to 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.
Definition at line 386 of file qfileinfo.cpp.
QFileInfo::QFileInfo | ( | const QFileInfo & | fileinfo | ) |
Constructs a new QFileInfo that is a copy of the given fileinfo.
Definition at line 394 of file qfileinfo.cpp.
QFileInfo::~QFileInfo | ( | ) |
Destroys the QFileInfo and frees its resources.
Definition at line 404 of file qfileinfo.cpp.
QDir QFileInfo::absoluteDir | ( | ) | const |
Returns the file's absolute path as a QDir object.
Definition at line 921 of file qfileinfo.cpp.
References absolutePath().
Referenced by changeInstallName(), createImageNode(), deployRPaths(), qRelocateResourceFile(), Viewer::saveImage(), and QFileDialog::selectFile().
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.
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.
Definition at line 556 of file qfileinfo.cpp.
References QAbstractFileEngine::AbsoluteName, and d.
Referenced by QIconCacheGtkReader::QIconCacheGtkReader(), TestCaseCollector::TestCaseCollector(), _qt_get_directory(), QQmlTypeLoader::absoluteFilePath(), QFileDialog::accept(), QPixmapIconEngine::addFile(), QSvgIconEngine::addFile(), Parser::addIncludesRecursive(), QQmlJSLinter::applyFixes(), QDir::cd(), changeInstallName(), codesignBundle(), combinePath(), compilerRunTimeLibs(), deploy(), deployRPaths(), deployTranslations(), deployWebEngineCore(), QGtk3Interface::fileIcon(), fileType(), findFilesRecursively(), freeDesktopTrashLocation(), QConfFile::fromName(), QUrl::fromUserInput(), QFileInfoGatherer::getInfo(), handleCompileErrors(), QFileIconProvider::icon(), QGenericUnixTheme::iconFallbackPaths(), iconThemeSearchPaths(), QQmlPluginImporter::importDynamicPlugin(), QSSGAssetImportManager::importFile(), QQmlPluginImporter::importPlugins(), QFile::link(), QQmlJSLinter::lintFile(), QPixmap::load(), loadModelShapeMesh(), makeAbsolute(), parseArguments(), QRhiMetal::pipelineCacheData(), QFreeTypeFontDatabase::populateFontDatabase(), QAndroidPlatformFontDatabase::populateFontDatabase(), QSvgHandler::processingInstruction(), QQml_isFileCaseCorrect(), quick_test_main_with_setup(), QQmlDataBlob::SourceCodeData::readAll(), resolveBugListFile(), Parser::resolveInclude(), Viewer::saveImage(), scanImports(), QRhiMetal::setPipelineCacheData(), translateDriveName(), QAbstractFileIconProvider::type(), updateLibrary(), QQuickFileDialogImplPrivate::updateSelectedFile(), RCCFileInfo::writeDataBlob(), QQmlToolingSettings::writeDefaults(), and QGenericUnixTheme::xdgIconThemePaths().
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.
Definition at line 599 of file qfileinfo.cpp.
References QAbstractFileEngine::AbsolutePathName, and d.
Referenced by _qt_get_directory(), absoluteDir(), Parser::addIncludesRecursive(), QTranslatorPrivate::do_load(), QZipReader::extractAll(), findFilesRecursively(), findMinGWRuntimePaths(), QQmlPluginImporter::importDynamicPlugin(), QCss::Parser::init(), QQmlDataTest::initTestCase(), QConfFile::isWritable(), QTextDocument::loadResource(), parseArguments(), readInputFile(), QTextBrowserPrivate::resolveUrl(), scanImports(), QTest::setMainSourcePath(), updateFile(), and writeDependencyFile().
QString QFileInfo::baseName | ( | ) | const |
Returns the base name of the file without the path.
The base name consists of all characters in the file up to (but not including) the first '.' character.
Example:
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").
Definition at line 817 of file qfileinfo.cpp.
References QAbstractFileEngine::BaseName, QFileSystemEntry::baseName(), and d.
Referenced by detectLatestAndroidPlatform(), handleCompileErrors(), Driver::headerFileName(), QDeferredFactory< QQmlJSScope >::internalName(), QQmlJSTypeReader::operator()(), parseProvider(), qQmlJSSymbolNamespaceForPath(), quasiLexicographicalReverseLessThan(), quick_test_main_with_setup(), QImageReader::read(), Viewer::saveImage(), and QQmlJS::Dom::QQmlDomAstCreator::visit().
|
inline |
Returns the date and time when the file was created (born), in local time.
If the file birth time is not available, this function returns an invalid QDateTime.
If the file is a symlink, the time of the target file is returned (not the symlink).
This function overloads QFileInfo::birthTime(const QTimeZone &tz), and returns the same as {birthTime(QTimeZone::LocalTime)}.
Definition at line 154 of file qfileinfo.h.
References QFileDevice::FileBirthTime.
Referenced by QNetworkDiskCache::expire().
Returns the date and time when the file was created (born).
file-times-in-time-zone
If the file birth time is not available, this function returns an invalid QDateTime.
If the file is a symlink, the time of the target file is returned (not the symlink).
Definition at line 160 of file qfileinfo.h.
References QFileDevice::FileBirthTime.
QString QFileInfo::bundleName | ( | ) | const |
On \macos and iOS this returns the proper localized name for a bundle if the path isBundle(). On all other platforms an empty QString is returned.
Example:
Definition at line 793 of file qfileinfo.cpp.
References QAbstractFileEngine::BundleName, and d.
Referenced by checkExecutable().
bool QFileInfo::caching | ( | ) | const |
Returns true
if caching is enabled; otherwise returns false
.
Definition at line 1685 of file qfileinfo.cpp.
References d.
Referenced by setFile().
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.
Definition at line 573 of file qfileinfo.cpp.
References QAbstractFileEngine::CanonicalName, and d.
Referenced by QFileDialogPrivate::_q_updateOkButton(), QFseventsFileSystemWatcherEngine::addPaths(), QQmlJS::Dom::QmlDirectory::addQmlFilePath(), QCoreApplication::applicationFilePath(), changeInstallName(), QSSGQmlUtilities::copyTextureAsset(), QFileSystemModel::filePath(), QCocoaFileIconEngine::filePixmap(), QQmlJS::Dom::QmldirFile::fromPathAndCode(), QFileInfoGatherer::getInfo(), getLibraryProjectsInOutputFolder(), QSSGInputUtil::getStreamForFile(), QDefaultOutputMapping::load(), QQmlJS::Dom::DomEnvironment::loadBuiltins(), QQmlJSResourceFileMapper::localFileFilter(), operator==(), parseOptions(), Moc::parsePluginData(), QDirIteratorPrivate::pushDirectory(), pythonRoot(), QTest::qFindTestData(), QQmlJS::Dom::ModuleIndex::qmldirsToLoad(), QQml_isFileCaseCorrect(), QFseventsFileSystemWatcherEngine::removePaths(), SharedImageProvider::requestImage(), resolveFileName(), Preprocessor::resolveInclude(), retrieveLabel(), and searchIncludePaths().
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.
Definition at line 616 of file qfileinfo.cpp.
References QAbstractFileEngine::CanonicalPathName, and d.
Referenced by changeInstallName(), QQmlJSImportVisitor::implicitImportDirectory(), QQmlJSAotCompiler::setDocument(), and QQmlJS::Dom::QQmlDomAstCreator::visit().
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:
Definition at line 838 of file qfileinfo.cpp.
References QAbstractFileEngine::BaseName, QFileSystemEntry::completeBaseName(), and d.
Referenced by AssimpImporter::import(), moc(), and qtResourceNameForFile().
QString QFileInfo::completeSuffix | ( | ) | const |
Returns the complete suffix (extension) of the file.
The complete suffix consists of all characters in the file after (but not including) the first '.'.
Example:
Definition at line 860 of file qfileinfo.cpp.
References d.
Referenced by QLibrary::isLibrary(), QPixmap::load(), QV4::ExecutableCompilationUnit::localCacheFilePath(), MainWindow::openFile(), QQuickNinePatchImage::pixmapChange(), and qQmlJSSymbolNamespaceForPath().
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 the QDir {"~/examples/191697"}.
For each of the following, dir() returns the QDir {"."}.
Definition at line 910 of file qfileinfo.cpp.
References d.
Referenced by combinePath(), QNetworkAccessFileBackendFactory::create(), main(), QQmlLocalStorage::openDatabaseSync(), Moc::parsePluginData(), quick_test_main_with_setup(), QQmlToolingSettings::search(), setFile(), and QQuickFileDialogImpl::setInitialCurrentFolderAndSelectedFile().
bool QFileInfo::exists | ( | ) | const |
Returns true
if the file exists; otherwise returns false
.
Definition at line 696 of file qfileinfo.cpp.
References d, QFileSystemMetaData::ExistsAttribute, QAbstractFileEngine::ExistsFlag, and QFileSystemEngine::fillMetaData().
Referenced by QIconCacheGtkReader::QIconCacheGtkReader(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QSSGShaderCache::QSSGShaderCache(), QFileDialogPrivate::_q_pathChanged(), _qt_get_directory(), QFileDialog::accept(), Parser::addIncludesRecursive(), QPollingFileSystemWatcherEngine::addPaths(), checkNeedPortalSupport(), checkNeedPortalSupport(), copyAndroidExtraLibs(), copyAndroidExtraResources(), copyDylib(), QSSGQmlUtilities::copyTextureAsset(), QNetworkAccessFileBackendFactory::create(), createDirectory(), deployWebEngineCore(), QQmlTypeLoader::directoryExists(), existingImageFileForPath(), QFile::exists(), QDir::exists(), QFileSystemModel::filePath(), findFilesRecursively(), findFilesRecursively(), findInPath(), QUrl::fromUserInput(), QFileInfoGatherer::getInfo(), getLibraryProjectsInOutputFolder(), QSSGAssetImportManager::getOptionsForFile(), QSSGInputUtil::getStreamForFile(), iconTempPath(), QSSGAssetImportManager::importFile(), importImp(), QConfFile::isWritable(), QPixmap::load(), loadModelShapeMesh(), QTextDocument::loadResource(), AndroidStyle::loadStyleData(), QDirIteratorPrivate::matchesFilters(), QFileSystemModelPrivate::node(), QSaveFile::open(), parseArguments(), parseEarlyArguments(), Moc::parsePluginData(), QSvgHandler::processingInstruction(), QTest::qFindTestData(), quick_test_main_with_setup(), Preprocessor::resolveInclude(), Parser::resolveInclude(), QTextBrowserPrivate::resolveUrl(), QWindowsFileSystemWatcherEngineThread::run(), QDBusXmlToCpp::run(), scanImports(), searchIncludePaths(), QQuickFolderListModel::setFolder(), QQuickFolderListModel::setRootFolder(), QFileSystemModel::setRootPath(), QExtendedInformation::size(), QQuickFolderBreadcrumbBarPrivate::textFieldAccepted(), QExtendedInformation::type(), updateFile(), and updateFile().
|
static |
Returns true
if the file exists; otherwise returns false
.
QFileInfo(file)
.exists() for file system access. Definition at line 720 of file qfileinfo.cpp.
References QFileInfo(), engine, QFileSystemMetaData::ExistsAttribute, file, QFileSystemEngine::fillMetaData(), and QFileSystemEngine::resolveEntryAndCreateLegacyEngine().
QString QFileInfo::fileName | ( | ) | const |
Returns the name of the file, excluding the path.
Example:
Note that, if this QFileInfo object is given a path ending in a slash, the name of the file is considered empty.
Definition at line 771 of file qfileinfo.cpp.
References QAbstractFileEngine::BaseName, and d.
Referenced by QFileDialogArgs::QFileDialogArgs(), QFileDialogPrivate::_q_updateOkButton(), QFileDialog::accept(), QFileDialogPrivate::addDefaultSuffixToFiles(), Parser::addIncludesRecursive(), QAbstractFileIconEngine::cacheKey(), QWindowsFileIconEngine::cacheKey(), QTextureFileReader::canRead(), changeInstallName(), QDirIteratorPrivate::checkAndPushDirectory(), copyAndroidExtraLibs(), QSSGQmlUtilities::copyTextureAsset(), QWindowsFileDialogHelper::createNativeDialog(), QFSFileEngineIterator::currentFileName(), deploy(), deployWebEngineCore(), QAndroidStyle::AndroidImageDrawable::draw(), QAndroidStyle::Android9PatchDrawable::draw(), QNetworkDiskCache::expire(), QDirIterator::fileName(), QEglFSDeviceIntegration::framebufferIndex(), QFileInfoGatherer::getInfo(), QBenchmarkValgrindUtils::getNewestFileName(), QLockFilePrivate::isProcessRunning(), main(), moc(), QQmlLocalStorage::openDatabaseSync(), QDirSortItemComparator::operator()(), patchQtCore(), qtResourceNameForFile(), QNetworkDiskCachePrivate::removeFile(), retrieveLabel(), QFileSelectorPrivate::select(), QQmlJSAotCompiler::setDocument(), QQuickImageSelector::setUrl(), sm_performSaveYourself(), QDirPrivate::sortFileList(), JsonOutput::toList(), translateDriveName(), updateFile(), updateFile(), updateLibsXml(), QWidget::windowTitle(), writeEtw(), and writeLttng().
QString QFileInfo::filePath | ( | ) | const |
Returns the file name, including the path (which may be absolute or relative).
Definition at line 752 of file qfileinfo.cpp.
References d.
Referenced by combinePath(), copyAndroidExtraLibs(), QAbstractFileEngineIterator::currentFileInfo(), deployWebEngineCore(), QNetworkDiskCache::expire(), QZipReader::extractAll(), QDirIterator::filePath(), QFileSystemModel::filePath(), findFilesRecursively(), QFileInfoGatherer::getInfo(), loadTzTimeZones(), QMimeDatabase::mimeTypeForFile(), QFileSystemEngine::moveFileToTrash(), QSaveFile::open(), operator<<(), QDirIteratorPrivate::pushDirectory(), QTest::qFindTestData(), searchIncludePaths(), and QCocoaFileDialogHelper::selectFile().
QDateTime QFileInfo::fileTime | ( | QFile::FileTime | time | ) | const |
QDateTime QFileInfo::fileTime | ( | QFile::FileTime | time, |
const QTimeZone & | tz | ||
) | const |
Returns the file time specified by \a time.
! [file-times-in-time-zone] The returned time is in the time zone specified by tz. For example, you can use QTimeZone::LocalTime or QTimeZone::UTC to get the time in the Local time zone or UTC, respectively. Since native file system API typically uses UTC, using QTimeZone::UTC is often faster, as it does not require any conversions. ! [file-times-in-time-zone]
If the time cannot be determined, an invalid date time is returned. If the file is a symlink, the time of the target file is returned (not the symlink). \since 6.6 \sa birthTime(const QTimeZone &), lastModified(const QTimeZone &), lastRead(const QTimeZone &), metadataChangeTime(const QTimeZone &), QDateTime::isValid()
Definition at line 1641 of file qfileinfo.cpp.
References QAbstractFileEngine::AccessTime, QFileSystemMetaData::AccessTime, QAbstractFileEngine::BirthTime, QFileSystemMetaData::BirthTime, d, QFileDevice::FileAccessTime, QFileDevice::FileBirthTime, QFileDevice::FileMetadataChangeTime, QFileDevice::FileModificationTime, QAbstractFileEngine::MetadataChangeTime, QFileSystemMetaData::MetadataChangeTime, QAbstractFileEngine::ModificationTime, QFileSystemMetaData::ModificationTime, time, and QDateTime::toTimeZone().
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).
If the file is a symlink, this function returns the owning group of the target (not the symlink).
Definition at line 1362 of file qfileinfo.cpp.
References d, and QAbstractFileEngine::OwnerGroup.
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.
If the file is a symlink, this function returns the id of the group owning the target (not the symlink).
Definition at line 1381 of file qfileinfo.cpp.
References d, QFileSystemMetaData::GroupId, and QAbstractFileEngine::OwnerGroup.
Referenced by QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), and QWindowsFileSystemWatcherEngine::PathInfo::operator=().
|
inline |
Returns true
if the file path is absolute, otherwise returns false
(i.e.
the path is relative).
Definition at line 116 of file qfileinfo.h.
References isRelative().
Referenced by _qt_get_directory(), QFileDialogPrivate::addDefaultSuffixToFiles(), QTextDocument::loadResource(), QTest::qFindTestData(), and QTextBrowserPrivate::resolveUrl().
bool QFileInfo::isAlias | ( | ) | const |
Returns true
if this object points to an alias; otherwise returns false
.
Aliases only exist on \macos. They are treated as regular files, so opening an alias will open the file itself. In order to open the file or directory an alias references use symLinkTarget().
Definition at line 1189 of file qfileinfo.cpp.
References d, QFileSystemMetaData::LegacyLinkType, and QAbstractFileEngine::LinkType.
bool QFileInfo::isBundle | ( | ) | const |
true
if this object points to a bundle or to a symbolic link to a bundle on \macos and iOS; otherwise returns false
.If the file is a symlink, this function returns true if the target is a bundle (not the symlink).
Definition at line 1077 of file qfileinfo.cpp.
References QAbstractFileEngine::BundleType, QFileSystemMetaData::BundleType, and d.
Referenced by checkExecutable().
bool QFileInfo::isDir | ( | ) | const |
Returns true
if this object points to a directory or to a symbolic link to a directory.
Returns false
if the object points to something that is not a directory (such as a file) or that does not exist.
If the file is a symlink, this function returns true if the target is a directory (not the symlink).
Definition at line 1057 of file qfileinfo.cpp.
References d, QAbstractFileEngine::DirectoryType, and QFileSystemMetaData::DirectoryType.
Referenced by QFileDialogArgs::QFileDialogArgs(), QIconTheme::QIconTheme(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QFileDialogPrivate::_q_updateOkButton(), _qt_get_directory(), QFileDialog::accept(), QFileDialogPrivate::addDefaultSuffixToFiles(), QInotifyFileSystemWatcherEngine::addPaths(), QPollingFileSystemWatcherEngine::addPaths(), QDirIteratorPrivate::checkAndPushDirectory(), QQuickFileDialogDelegatePrivate::chooseFile(), copyAndroidExtraResources(), createDirectory(), QWindowsFileDialogHelper::createNativeDialog(), deployWebEngineCore(), QQmlTypeLoader::directoryExists(), QZipReader::extractAll(), QWindowsFileIconEngine::filePixmap(), findFilesRecursively(), freeDesktopTrashLocation(), QAbstractFileIconProviderPrivate::getIconThemeIcon(), getLibraryProjectsInOutputFolder(), QQuickFileDialogImplPrivate::handleClick(), QFileIconProvider::icon(), QGenericUnixTheme::iconFallbackPaths(), iconThemeSearchPaths(), QFileSystemModelPrivate::QFileSystemNode::isDir(), QFileSystemModel::isDir(), loadTzTimeZones(), QDirIteratorPrivate::matchesFilters(), QMimeDatabasePrivate::mimeTypeForFile(), QFileSystemEngine::moveFileToTrash(), QNetworkFile::open(), QSaveFile::open(), QDirSortItemComparator::operator()(), parseArguments(), Moc::parsePluginData(), quick_test_main_with_setup(), QFseventsFileSystemWatcherEngine::removePaths(), QDir::removeRecursively(), Preprocessor::resolveInclude(), QQmlToolingSettings::search(), searchIncludePaths(), QQuickFolderListModel::setFolder(), QQuickFolderListModel::setRootFolder(), QFileSystemModelPrivate::QFileSystemNode::size(), QQuickFolderBreadcrumbBarPrivate::textFieldAccepted(), QExtendedInformation::type(), QAbstractFileIconProvider::type(), updateFile(), updateFile(), vcRedistDir(), and QGenericUnixTheme::xdgIconThemePaths().
bool QFileInfo::isExecutable | ( | ) | const |
Returns true
if the file is executable; otherwise returns false
.
If the file is a symlink, this function returns true if the target is executable (not the symlink).
Definition at line 974 of file qfileinfo.cpp.
References d, QFileDevice::ExeUser, QAbstractFileEngine::ExeUserPerm, and QFileSystemMetaData::UserExecutePermission.
Referenced by bluetoothdVersion(), QAbstractFileIconEngine::cacheKey(), checkExecutable(), findInPath(), QDirIteratorPrivate::matchesFilters(), and parseEarlyArguments().
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 that is not a file (such as a directory) or that does not exist.
If the file is a symlink, this function returns true if the target is a regular file (not the symlink).
Definition at line 1037 of file qfileinfo.cpp.
References d, QAbstractFileEngine::FileType, and QFileSystemMetaData::FileType.
Referenced by QQmlTypeLoader::absoluteFilePath(), QAbstractFileIconEngine::cacheKey(), checkExecutable(), compilerRunTimeLibs(), deploy(), existsAsSpecified(), QZipReader::extractAll(), findInPath(), QFileInfoGatherer::getInfo(), QFileIconProvider::icon(), is_readable_file(), QFileSystemModelPrivate::QFileSystemNode::isFile(), QTranslator::load(), QQmlJS::Dom::DomEnvironment::loadBuiltins(), QQmlJS::Dom::DomEnvironment::loadModuleDependency(), loadTzTimeZones(), QDirIteratorPrivate::matchesFilters(), QmlDirectoryFileEntryFunction::operator()(), parseArguments(), QQmlJS::Dom::ModuleIndex::qmldirsToLoad(), quick_test_main_with_setup(), QFileSystemModel::remove(), resolveBugListFile(), QDBusXmlToCpp::run(), QExtendedInformation::type(), QAbstractFileIconProvider::type(), and updateLibrary().
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. And note that, since this function inspects the file name, on Unix it will inspect the name of the symlink, if this file is a symlink, not the target's name.
On Windows, this function returns true
if the target file is hidden (not the symlink).
Definition at line 994 of file qfileinfo.cpp.
References d, QFileSystemMetaData::HiddenAttribute, and QAbstractFileEngine::HiddenFlag.
Referenced by QDirIteratorPrivate::checkAndPushDirectory(), QExtendedInformation::isHidden(), QFileSystemModelPrivate::QFileSystemNode::isHidden(), and QDirIteratorPrivate::matchesFilters().
bool QFileInfo::isJunction | ( | ) | const |
Returns true
if the object points to a junction; otherwise returns false
.
Junctions only exist on Windows' NTFS file system, and are typically created by the {mklink} command. They can be thought of as symlinks for directories, and can only be created for absolute paths on the local volume.
Definition at line 1209 of file qfileinfo.cpp.
References d, QFileSystemMetaData::LegacyLinkType, and QAbstractFileEngine::LinkType.
bool QFileInfo::isNativePath | ( | ) | const |
true
if the file path can be used directly with native APIs. Returns false
if the file is otherwise supported by a virtual file system inside Qt, such as \l{the Qt Resource System}.{Note:} Native paths may still require conversion of path separators and character encoding, depending on platform and input requirements of the native API.
Definition at line 1016 of file qfileinfo.cpp.
References d, and QAbstractFileEngine::LocalDiskFlag.
Referenced by QSSGInputUtil::getStreamForFile(), and QMimeDatabasePrivate::mimeTypeForFile().
bool QFileInfo::isReadable | ( | ) | const |
Returns true
if the user can read the file; otherwise returns false
.
If the file is a symlink, this function returns true if the target is readable (not the symlink).
Definition at line 937 of file qfileinfo.cpp.
References d, QFileDevice::ReadUser, QAbstractFileEngine::ReadUserPerm, and QFileSystemMetaData::UserReadPermission.
Referenced by QTextBrowserPrivate::findFile(), QFileInfoGatherer::getInfo(), is_readable_file(), QTranslator::load(), QDirIteratorPrivate::matchesFilters(), and QDBusXmlToCpp::run().
bool QFileInfo::isRelative | ( | ) | const |
Returns true
if the file path is relative, otherwise returns false
(i.e.
the path is absolute). (E.g. under Unix a path is absolute if it begins with a "/").
Definition at line 663 of file qfileinfo.cpp.
References d.
Referenced by QSSGQmlUtilities::copyTextureAsset(), QDir::isRelativePath(), QAndroidCaptureSession::start(), and QQmlJSImportVisitor::visit().
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 1223 of file qfileinfo.cpp.
References d, QFileSystemMetaData::ExistsAttribute, QFileSystemEngine::fillMetaData(), and QAbstractFileEngine::RootFlag.
Referenced by QWindowsFileIconEngine::filePixmap(), and QAbstractFileIconProviderPrivate::getIconThemeIcon().
bool QFileInfo::isShortcut | ( | ) | const |
Returns true
if this object points to a shortcut; otherwise returns false
.
Shortcuts only exist on Windows and are typically .lnk files. For instance, true will be returned for shortcuts (
*
.lnk files) on Windows, but false will be returned on Unix (including \macos and iOS).
The shortcut (.lnk) files are treated as regular files. Opening those will open the .lnk file itself. In order to open the file a shortcut references to, it must uses symLinkTarget() on a shortcut.
Definition at line 1165 of file qfileinfo.cpp.
References d, QFileSystemMetaData::LegacyLinkType, and QAbstractFileEngine::LinkType.
bool QFileInfo::isSymbolicLink | ( | ) | const |
Returns true
if this object points to a symbolic link; otherwise returns false
.
Symbolic links exist on Unix (including \macos and iOS) and Windows (NTFS-symlink) and are typically created by the {ln -s} or
{mklink} commands, respectively.
Unix handles symlinks transparently. Opening a symbolic link effectively opens the \l{symLinkTarget()}{link's target}.
In contrast to isSymLink(), false will be returned for shortcuts (*
.lnk files) on Windows and aliases on \macos. Use QFileInfo::isShortcut() and QFileInfo::isAlias() instead.
Definition at line 1139 of file qfileinfo.cpp.
References d, QFileSystemMetaData::LegacyLinkType, and QAbstractFileEngine::LinkType.
bool QFileInfo::isSymLink | ( | ) | const |
Returns true
if this object points to a symbolic link, shortcut, or alias; otherwise returns false
.
Symbolic links exist on Unix (including \macos and iOS) and Windows and are typically created by the {ln -s} or
{mklink} commands, respectively. Opening a symbolic link effectively opens the \l{symLinkTarget()}{link's target}.
In addition, true will be returned for shortcuts (*
.lnk files) on Windows, and aliases on \macos. This behavior is deprecated and will likely change in a future version of Qt. Opening a shortcut or alias will open the .lnk or alias file itself.
Example:
Definition at line 1109 of file qfileinfo.cpp.
References d, QFileSystemMetaData::LegacyLinkType, and QAbstractFileEngine::LinkType.
Referenced by QFileDialogPrivate::_q_deleteCurrent(), QAbstractFileIconEngine::cacheKey(), QDirIteratorPrivate::checkAndPushDirectory(), QZipReader::extractAll(), QEglFSDeviceIntegration::framebufferIndex(), freeDesktopTrashLocation(), QFileInfoGatherer::getInfo(), QFileIconProvider::icon(), QLockFilePrivate::isProcessRunning(), QExtendedInformation::isSymLink(), QFileSystemModelPrivate::QFileSystemNode::isSymLink(), loadTzTimeZones(), QDirIteratorPrivate::matchesFilters(), QSaveFile::open(), QDirIteratorPrivate::pushDirectory(), QFileSystemModel::remove(), QDir::removeRecursively(), retrieveLabel(), runningUnderDebugger(), QExtendedInformation::size(), QExtendedInformation::type(), QAbstractFileIconProvider::type(), updateFile(), and updateFile().
bool QFileInfo::isWritable | ( | ) | const |
Returns true
if the user can write to the file; otherwise returns false
.
If the file is a symlink, this function returns true if the target is writeable (not the symlink).
Definition at line 957 of file qfileinfo.cpp.
References d, QFileSystemMetaData::UserWritePermission, QFileDevice::WriteUser, and QAbstractFileEngine::WriteUserPerm.
Referenced by ensureWritableDir(), ensureWritableDir(), QDirIteratorPrivate::matchesFilters(), QSaveFile::open(), and qt_ensureWritableDir().
QString QFileInfo::junctionTarget | ( | ) | const |
Resolves an NTFS junction to the path it references.
Returns the absolute path to the directory an NTFS junction points to, or an empty string if the object is not an NTFS junction.
There is no guarantee that the directory named by the NTFS junction actually exists.
Definition at line 1299 of file qfileinfo.cpp.
References d, and QAbstractFileEngine::JunctionName.
|
inline |
Returns the date and time when the file was last modified.
If the file is a symlink, the time of the target file is returned (not the symlink).
This function overloads \l{QFileInfo::lastModified(const QTimeZone &)}, and returns the same as {lastModified(QTimeZone::LocalTime)}.
Definition at line 156 of file qfileinfo.h.
References QFileDevice::FileModificationTime.
Referenced by QIconCacheGtkReader::QIconCacheGtkReader(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QV4::ExecutionEngine::compileModule(), copyFileIfNewer(), QGeoFileTileCacheOsm::init(), QLockFilePrivate::isApparentlyStale(), QExtendedInformation::lastModified(), QFileSystemModelPrivate::QFileSystemNode::lastModified(), QMimeBinaryProvider::CacheFile::load(), QPixmap::load(), QNetworkFile::open(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QDirSortItemComparator::operator()(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), QExtendedInformation::operator==(), QLockFile::tryLock(), updateFile(), updateFile(), QV4::ExecutableCompilationUnit::verifyHeader(), and RCCFileInfo::writeDataInfo().
Returns the date and time when the file was last modified.
file-times-in-time-zone
If the file is a symlink, the time of the target file is returned (not the symlink).
Definition at line 162 of file qfileinfo.h.
References QFileDevice::FileModificationTime.
|
inline |
Returns the date and time when the file was last read (accessed).
On platforms where this information is not available, returns the same time as lastModified().
If the file is a symlink, the time of the target file is returned (not the symlink).
This function overloads \l{QFileInfo::lastRead(const QTimeZone &)}, and returns the same as {lastRead(QTimeZone::LocalTime)}.
Definition at line 157 of file qfileinfo.h.
References QFileDevice::FileAccessTime.
Returns the date and time when the file was last read (accessed).
file-times-in-time-zone
On platforms where this information is not available, returns the same time as lastModified().
If the file is a symlink, the time of the target file is returned (not the symlink).
Definition at line 163 of file qfileinfo.h.
References QFileDevice::FileAccessTime.
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.
Definition at line 680 of file qfileinfo.cpp.
References absoluteFilePath(), QSharedDataPointer< T >::constData(), d_ptr, QFileInfoPrivate::fileEntry, QFileInfoPrivate::isDefaultConstructed, QFileSystemEntry::isRelative(), and setFile().
|
inline |
Returns the date and time when the file's metadata was last changed, in local time.
A metadata change occurs when the file is first created, but it also occurs whenever the user writes or sets inode information (for example, changing the file permissions).
If the file is a symlink, the time of the target file is returned (not the symlink).
This function overloads QFileInfo::metadataChangeTime(const QTimeZone &tz), and returns the same as {metadataChangeTime(QTimeZone::LocalTime)}.
Definition at line 155 of file qfileinfo.h.
References QFileDevice::FileMetadataChangeTime.
Referenced by QNetworkDiskCache::expire().
Returns the date and time when the file's metadata was last changed.
A metadata change occurs when the file is first created, but it also occurs whenever the user writes or sets inode information (for example, changing the file permissions).
file-times-in-time-zone
If the file is a symlink, the time of the target file is returned (not the symlink).
Definition at line 161 of file qfileinfo.h.
References QFileDevice::FileMetadataChangeTime.
|
inline |
Returns true
if this QFileInfo object refers to a different file than the one specified by fileinfo; otherwise returns false
.
Definition at line 62 of file qfileinfo.h.
References operator==().
Move-assigns other to this QFileInfo instance.
Makes a copy of the given fileinfo and assigns it to this QFileInfo.
Definition at line 466 of file qfileinfo.cpp.
References d_ptr.
bool QFileInfo::operator== | ( | const QFileInfo & | fileinfo | ) | const |
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 (file paths that do not exist or are empty), is undefined.
Definition at line 433 of file qfileinfo.cpp.
References canonicalFilePath(), Qt::CaseInsensitive, Qt::CaseSensitive, QString::compare(), d, d_ptr, QFileInfoPrivate::fileEngine, QFileInfoPrivate::fileEntry, QFileSystemEntry::filePath(), QFileSystemEngine::isCaseSensitive(), and QFileInfoPrivate::isDefaultConstructed.
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). On Windows, it will return an empty string unless the \l{NTFS permissions} check has been enabled.
If the file is a symlink, this function returns the owner of the target (not the symlink).
Definition at line 1321 of file qfileinfo.cpp.
References d, and QAbstractFileEngine::OwnerUser.
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).
If the file is a symlink, this function returns the id of the owner of the target (not the symlink).
Definition at line 1340 of file qfileinfo.cpp.
References d, QAbstractFileEngine::OwnerUser, and QFileSystemMetaData::UserId.
Referenced by QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), and QWindowsFileSystemWatcherEngine::PathInfo::operator=().
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.
Definition at line 633 of file qfileinfo.cpp.
References d.
Referenced by QFileDialog::accept(), QFseventsFileSystemWatcherEngine::addPaths(), QCoreApplication::applicationDirPath(), QPainter::clipBoundingRect(), QPainter::clipRegion(), deployPlugins(), operator<<(), qQmlJSSymbolNamespaceForPath(), QWasmIDBSettingsPrivate_onLoad(), RCCResourceLibrary::readFiles(), QFseventsFileSystemWatcherEngine::removePaths(), QPaintEngineExPrivate::replayClipOperations(), QPainter::restore(), QFileSelectorPrivate::select(), QQuickImageSelector::setUrl(), and QQmlApplicationEnginePrivate::startLoad().
bool QFileInfo::permission | ( | QFile::Permissions | permissions | ) | const |
Tests for file permissions.
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:
If the file is a symlink, this function checks the permissions of the target (not the symlink).
Definition at line 1409 of file qfileinfo.cpp.
References d, and permissions().
QFile::Permissions QFileInfo::permissions | ( | ) | const |
Returns the complete OR-ed together combination of QFile::Permissions for the file.
If the file is a symlink, this function returns the permissions of the target (not the symlink).
Definition at line 1433 of file qfileinfo.cpp.
References d, QFileSystemMetaData::Permissions, and QAbstractFileEngine::PermsMask.
Referenced by QZipReader::extractAll(), QSaveFile::open(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), QExtendedInformation::operator==(), permission(), QExtendedInformation::permissions(), and QFileSystemModelPrivate::QFileSystemNode::permissions().
QString QFileInfo::readSymLink | ( | ) | const |
Returns the raw path referenced by the symbolic link, without resolving a relative path relative to the directory containing the symbolic link. The returned string will only be an absolute path if the symbolic link actually references it as such. Returns an empty string if the object is not a symbolic link.
Definition at line 1277 of file qfileinfo.cpp.
References d, and QAbstractFileEngine::RawLinkPath.
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.
Definition at line 740 of file qfileinfo.cpp.
References d.
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.
Definition at line 1703 of file qfileinfo.cpp.
References d.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the file that the QFileInfo provides information about to file in directory dir.
If file includes a relative path, the QFileInfo will also have a relative path.
Definition at line 529 of file qfileinfo.cpp.
References dir(), file, QDir::filePath(), and setFile().
void QFileInfo::setFile | ( | const QFileDevice & | file | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the file that the QFileInfo provides information about to file.
If file includes a relative path, the QFileInfo will also have a relative path.
Definition at line 513 of file qfileinfo.cpp.
References file, QFile::fileName(), and setFile().
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:
Definition at line 495 of file qfileinfo.cpp.
References QFileInfo(), QFileInfoPrivate::cache_enabled, caching(), QSharedDataPointer< T >::constData(), d_ptr, and file.
Referenced by compilerRunTimeLibs(), QAbstractFileEngineIterator::currentFileInfo(), QSSGInputUtil::getStreamForFile(), QLockFilePrivate::isProcessRunning(), QTranslator::load(), makeAbsolute(), QSaveFile::open(), Moc::parsePluginData(), QTest::qFindTestData(), Preprocessor::resolveInclude(), searchIncludePaths(), setFile(), setFile(), and QTest::setMainSourcePath().
qint64 QFileInfo::size | ( | ) | const |
Returns the file size in bytes.
If the file does not exist or cannot be fetched, 0 is returned.
If the file is a symlink, the size of the target file is returned (not the symlink).
Definition at line 1454 of file qfileinfo.cpp.
References QFileInfoPrivate::CachedSize, d, and QFileSystemMetaData::SizeAttribute.
Referenced by QNetworkReplyFileImpl::QNetworkReplyFileImpl(), DatabaseInfo::acceptWidget(), QDockAreaLayout::addDockWidget(), addTagToMap(), QGeoFileTileCache::addToDiskCache(), QSSGRhiContextStats::beginRenderPass(), Decoder::doDecode(), QNetworkDiskCache::expire(), QDockAreaLayout::gapRect(), QToolBarAreaLayout::item(), QPixmap::load(), QGeoFileTileCache::loadTiles(), main(), QMoviePrivate::next(), QNetworkFile::open(), QDirSortItemComparator::operator()(), QtAndroidAccessibility::populateNode(), qCleanupFuncinfo(), QQmlDataBlob::SourceCodeData::readAll(), realMaxSize(), realMinSize(), QNetworkDiskCachePrivate::removeFile(), QDockAreaLayout::resizeDocks(), QOpenGLProgramBinaryCache::save(), QExtendedInformation::size(), QFileSystemModelPrivate::QFileSystemNode::size(), and QSSGRhiContextStats::stop().
void QFileInfo::stat | ( | ) |
Reads all attributes from the file system.
This is useful when information about the file system is collected in a worker thread, and then passed to the UI in the form of caching QFileInfo instances.
Definition at line 1719 of file qfileinfo.cpp.
References QFileSystemMetaData::AllMetaDataFlags, d, and QFileSystemEngine::fillMetaData().
QString QFileInfo::suffix | ( | ) | const |
Returns the suffix (extension) of the file.
The suffix consists of all characters in the file after (but not including) the last '.'.
Example:
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").
Definition at line 883 of file qfileinfo.cpp.
References d.
Referenced by QDirSortItem::QDirSortItem(), QFileDialogPrivate::_q_useNameFilter(), QIcon::addFile(), QQmlJSLinter::applyFixes(), QAbstractFileIconEngine::cacheKey(), QWindowsFileIconEngine::cacheKey(), QTextureFileReader::canRead(), copyAndroidExtraLibs(), createReadHandlerHelper(), createWriteHandlerHelper(), existingImageFileForPath(), QStandardPaths::findExecutable(), QGeoFileTileCache::getFromDisk(), QSSGAssetImportManager::getOptionsForFile(), QSSGInputUtil::getStreamForTextureFile(), hasSuffix(), QSSGAssetImportManager::importFile(), QExtendedInformation::isSymLink(), QQmlJSLinter::lintFile(), moc(), QQmlJSTypeReader::operator()(), QMediaPlayerPrivate::setMedia(), QPrinter::setOutputFileName(), and QTextDocumentWriter::write().
Swaps this file info with other. This function is very fast and never fails.
Definition at line 58 of file qfileinfo.h.
References other().
QString QFileInfo::symLinkTarget | ( | ) | const |
Returns the absolute path to the file or directory a symbolic link points to, or an empty string if the object isn't a symbolic link.
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.
Definition at line 1258 of file qfileinfo.cpp.
References QAbstractFileEngine::AbsoluteLinkTarget, and d.
Referenced by QEglFSDeviceIntegration::framebufferIndex(), freeDesktopTrashLocation(), QFileInfoGatherer::getInfo(), QLockFilePrivate::isProcessRunning(), QSaveFile::open(), retrieveLabel(), runningUnderDebugger(), QFile::symLinkTarget(), and updateFile().
|
friend |
Definition at line 23 of file qfileinfo.h.
|
related |
Synonym for QList<QFileInfo>.
Definition at line 183 of file qfileinfo.h.
|
protected |
Definition at line 171 of file qfileinfo.h.
Referenced by makeAbsolute(), operator=(), operator==(), QDirIteratorPrivate::pushDirectory(), and setFile().