Qt 4.8
|
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... | |
QFileInfo & | operator= (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< QFileInfoPrivate > | d_ptr |
Private Functions | |
QFileInfoPrivate * | d_func () |
const QFileInfoPrivate * | d_func () const |
Friends | |
class | QDirIteratorPrivate |
Related Functions | |
(Note that these are not member functions.) | |
QFileInfoList | |
Synonym for QList<QFileInfo>. More... | |
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 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:
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:
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.
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.
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).
Definition at line 60 of file qfileinfo.h.
|
explicit |
Definition at line 299 of file qfileinfo.cpp.
QFileInfo::QFileInfo | ( | ) |
Constructs an empty QFileInfo object.
Note that an empty QFileInfo object contain no file reference.
Definition at line 310 of file qfileinfo.cpp.
Referenced by setFile().
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 320 of file qfileinfo.cpp.
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.
Definition at line 333 of file qfileinfo.cpp.
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.
Definition at line 349 of file qfileinfo.cpp.
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.
QFileInfo::~QFileInfo | ( | ) |
Destroys the QFileInfo and frees its resources.
Definition at line 367 of file qfileinfo.cpp.
QDir QFileInfo::absoluteDir | ( | ) | const |
Returns the file's absolute path as a QDir object.
Definition at line 873 of file qfileinfo.cpp.
Referenced by QPollingFileSystemWatcherEngine::FileInfo::FileInfo(), QPollingFileSystemWatcherEngine::FileInfo::operator!=(), 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.
If the QFileInfo is empty it returns QDir::currentPath().
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().
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 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().
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:
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 773 of file qfileinfo.cpp.
Referenced by QCoreApplicationPrivate::appName(), and QScriptEnginePrivate::translationContextFromUrl().
QString QFileInfo::bundleName | ( | ) | const |
Returns the name of the bundle.
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:
Definition at line 749 of file qfileinfo.cpp.
bool QFileInfo::caching | ( | ) | const |
Returns true if caching is enabled; otherwise returns false.
Definition at line 1346 of file qfileinfo.cpp.
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 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().
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 598 of file qfileinfo.cpp.
Referenced by QDnotifyFileSystemWatcherEngine::addPaths(), QFSEventsFileSystemWatcherEngine::addPaths(), and QFSEventsFileSystemWatcherEngine::removePaths().
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 792 of file qfileinfo.cpp.
Referenced by QFileDialogPrivate::qt_mac_filedialog_event_proc().
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:
Definition at line 811 of file qfileinfo.cpp.
Referenced by QLibrary::isLibrary(), QPixmap::load(), and loadOpenSslWin32().
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().
Definition at line 1278 of file qfileinfo.cpp.
Referenced by QNetworkDiskCache::expire(), and qt_CoCreateGuid().
|
inlineprivate |
Definition at line 179 of file qfileinfo.h.
|
inlineprivate |
Definition at line 185 of file qfileinfo.h.
void QFileInfo::detach | ( | ) |
Detaches all internal data.
Definition at line 1336 of file qfileinfo.cpp.
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"
.
For each of the following, dir() returns a QDir for "."
.
Definition at line 861 of file qfileinfo.cpp.
Referenced by absoluteDir(), QDeclarativeImportsPrivate::importExtension(), QDirModel::remove(), QDirModel::rmdir(), and QDirModel::setData().
bool QFileInfo::exists | ( | ) | const |
Returns true if the file exists; otherwise returns false.
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().
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 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().
QString QFileInfo::filePath | ( | ) | const |
Returns the file name, including the path (which may be absolute or relative).
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().
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).
Definition at line 1167 of file qfileinfo.cpp.
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.
Definition at line 1183 of file qfileinfo.cpp.
Referenced by QPollingFileSystemWatcherEngine::FileInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), and QDnotifyFileSystemWatcherEngine::Directory::File::updateInfo().
|
inline |
Returns true if the file path name is absolute, otherwise returns false if the path is relative.
Definition at line 111 of file qfileinfo.h.
Referenced by QUrl::isParentOf(), and QFileDialog::selectFile().
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.
Definition at line 1014 of file qfileinfo.cpp.
bool QFileInfo::isDir | ( | ) | const |
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise returns false.
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().
bool QFileInfo::isExecutable | ( | ) | const |
Returns true if the file is executable; otherwise returns false.
Definition at line 932 of file qfileinfo.cpp.
Referenced by QFileIconProviderPrivate::getWinIcon(), and QDirIteratorPrivate::matchesFilters().
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.
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().
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().
bool QFileInfo::isReadable | ( | ) | const |
Returns true if the user can read the file; otherwise returns false.
Definition at line 896 of file qfileinfo.cpp.
Referenced by find_translation(), QFileInfoGatherer::getInfo(), QTranslator::load(), and QDirIteratorPrivate::matchesFilters().
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 "/").
Definition at line 642 of file qfileinfo.cpp.
Referenced by QDir::isRelativePath().
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().
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:
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().
bool QFileInfo::isWritable | ( | ) | const |
Returns true if the user can write to the file; otherwise returns false.
Definition at line 914 of file qfileinfo.cpp.
Referenced by QUnixPrintWidgetPrivate::checkFields(), QDirModel::flags(), and QDirIteratorPrivate::matchesFilters().
QDateTime QFileInfo::lastModified | ( | ) | const |
Returns the date and time when the file was last modified.
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().
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().
Definition at line 1317 of file qfileinfo.cpp.
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 659 of file qfileinfo.cpp.
Referenced by QGtkStylePrivate::setupGtkFileChooser().
|
inline |
Returns true if this QFileInfo object refers to a different file than the one specified by fileinfo; otherwise returns false.
Definition at line 80 of file qfileinfo.h.
|
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.
Makes a copy of the given fileinfo and assigns it to this QFileInfo.
Definition at line 447 of file qfileinfo.cpp.
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.
Definition at line 439 of file qfileinfo.cpp.
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.
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).
Definition at line 1128 of file qfileinfo.cpp.
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).
Definition at line 1144 of file qfileinfo.cpp.
Referenced by QPollingFileSystemWatcherEngine::FileInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator!=(), QWindowsFileSystemWatcherEngine::PathInfo::operator=(), and QDnotifyFileSystemWatcherEngine::Directory::File::updateInfo().
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 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().
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:
Definition at line 1209 of file qfileinfo.cpp.
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().
QString QFileInfo::readLink | ( | ) | const |
Use symLinkTarget() instead.
Definition at line 1110 of file qfileinfo.cpp.
Referenced by QFile::readLink().
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 695 of file qfileinfo.cpp.
Referenced by QPollingFileSystemWatcherEngine::timeout().
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 1364 of file qfileinfo.cpp.
Referenced by QDirModelPrivate::appendChild().
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:
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().
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.
Definition at line 489 of file qfileinfo.cpp.
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.
Definition at line 508 of file qfileinfo.cpp.
qint64 QFileInfo::size | ( | ) | const |
Returns the file size in bytes.
If the file does not exist or cannot be fetched, 0 is returned.
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().
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:
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 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().
|
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.
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 121 of file qfileinfo.h.
Referenced by QDirModelPrivate::children(), QFileInfoGatherer::getInfo(), QDirModelPrivate::resolvedInfo(), runningUnderDebugger(), and QFileSystemEngine::slowCanonicalized().
|
friend |
Definition at line 62 of file qfileinfo.h.
|
related |
Synonym for QList<QFileInfo>.
|
protected |
Definition at line 177 of file qfileinfo.h.
Referenced by detach(), makeAbsolute(), operator=(), operator==(), QDirIteratorPrivate::pushDirectory(), and setFile().