📄 qfileinfo.3qt
字号:
'\" t.TH QFileInfo 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQFileInfo \- System-independent file information.SH SYNOPSISAll the functions in this class are reentrant when Qt is built with thread support.</p>.PP\fC#include <qfileinfo.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBPermissionSpec\fR { ReadUser = 0400, WriteUser = 0200, ExeUser = 0100, ReadGroup = 0040, WriteGroup = 0020, ExeGroup = 0010, ReadOther = 0004, WriteOther = 0002, ExeOther = 0001 }".br.ti -1c.BI "\fBQFileInfo\fR ()".br.ti -1c.BI "\fBQFileInfo\fR ( const QString & file )".br.ti -1c.BI "\fBQFileInfo\fR ( const QFile & file )".br.ti -1c.BI "\fBQFileInfo\fR ( const QDir & d, const QString & fileName )".br.ti -1c.BI "\fBQFileInfo\fR ( const QFileInfo & fi )".br.ti -1c.BI "\fB~QFileInfo\fR ()".br.ti -1c.BI "QFileInfo & \fBoperator=\fR ( const QFileInfo & fi )".br.ti -1c.BI "void \fBsetFile\fR ( const QString & file )".br.ti -1c.BI "void \fBsetFile\fR ( const QFile & file )".br.ti -1c.BI "void \fBsetFile\fR ( const QDir & d, const QString & fileName )".br.ti -1c.BI "bool \fBexists\fR () const".br.ti -1c.BI "void \fBrefresh\fR () const".br.ti -1c.BI "bool \fBcaching\fR () const".br.ti -1c.BI "void \fBsetCaching\fR ( bool enable )".br.ti -1c.BI "QString \fBfilePath\fR () const".br.ti -1c.BI "QString \fBfileName\fR () const".br.ti -1c.BI "QString \fBabsFilePath\fR () const".br.ti -1c.BI "QString \fBbaseName\fR ( bool complete = FALSE ) const".br.ti -1c.BI "QString \fBextension\fR ( bool complete = TRUE ) const".br.ti -1c.BI "QString \fBdirPath\fR ( bool absPath = FALSE ) const".br.ti -1c.BI "QDir \fBdir\fR ( bool absPath = FALSE ) const".br.ti -1c.BI "bool \fBisReadable\fR () const".br.ti -1c.BI "bool \fBisWritable\fR () const".br.ti -1c.BI "bool \fBisExecutable\fR () const".br.ti -1c.BI "bool \fBisHidden\fR () const".br.ti -1c.BI "bool \fBisRelative\fR () const".br.ti -1c.BI "bool \fBconvertToAbs\fR ()".br.ti -1c.BI "bool \fBisFile\fR () const".br.ti -1c.BI "bool \fBisDir\fR () const".br.ti -1c.BI "bool \fBisSymLink\fR () const".br.ti -1c.BI "QString \fBreadLink\fR () const".br.ti -1c.BI "QString \fBowner\fR () const".br.ti -1c.BI "uint \fBownerId\fR () const".br.ti -1c.BI "QString \fBgroup\fR () const".br.ti -1c.BI "uint \fBgroupId\fR () const".br.ti -1c.BI "bool \fBpermission\fR ( int permissionSpec ) const".br.ti -1c.BI "uint \fBsize\fR () const".br.ti -1c.BI "QDateTime \fBcreated\fR () const".br.ti -1c.BI "QDateTime \fBlastModified\fR () const".br.ti -1c.BI "QDateTime \fBlastRead\fR () const".br.in -1c.SH DESCRIPTIONThe QFileInfo class provides system-independent file information..PPQFileInfo 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..PPA 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 convertToAbs() to convert a relative QFileInfo's path to an absolute path..PPThe 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..PPTo 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)..PPThe file's type is obtained with isFile(), isDir() and isSymLink(). The readLink() function provides the name of the file the symlink points to..PPElements of the file's name can be extracted with dirPath() and fileName(). The fileName()'s parts can be extracted with baseName() and extension()..PPThe 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..PPIf you need to read and traverse directories, see the QDir class..PPSee also Input/Output and Networking..SS "Member Type Documentation".SH "QFileInfo::PermissionSpec"This enum is used by the permission() function to report the permissions and ownership of a file. The values may be OR-ed together to test multiple permissions and ownership values..TP\fCQFileInfo::ReadUser\fR - The file is readable by the user..TP\fCQFileInfo::WriteUser\fR - The file is writable by the user..TP\fCQFileInfo::ExeUser\fR - The file is executable by the user..TP\fCQFileInfo::ReadGroup\fR - The file is readable by the group..TP\fCQFileInfo::WriteGroup\fR - The file is writable by the group..TP\fCQFileInfo::ExeGroup\fR - The file is executable by the group..TP\fCQFileInfo::ReadOther\fR - The file is readable by anyone..TP\fCQFileInfo::WriteOther\fR - The file is writable by anyone..TP\fCQFileInfo::ExeOther\fR - The file is executable by anyone..SH MEMBER FUNCTION DOCUMENTATION.SH "QFileInfo::QFileInfo ()"Constructs a new empty QFileInfo..SH "QFileInfo::QFileInfo ( const QString & file )"Constructs a new QFileInfo that gives information about the given file. The \fIfile\fR can also include an absolute or relative path..PPSee also setFile(), isRelative(), QDir::setCurrent(), and QDir::isRelativePath()..SH "QFileInfo::QFileInfo ( const QFile & file )"Constructs a new QFileInfo that gives information about file \fIfile\fR..PPIf the \fIfile\fR has a relative path, the QFileInfo will also have a relative path..PPSee also isRelative()..SH "QFileInfo::QFileInfo ( const QDir & d, const QString & fileName )"Constructs a new QFileInfo that gives information about the file called \fIfileName\fR in the directory \fId\fR..PPIf \fId\fR has a relative path, the QFileInfo will also have a relative path..PPSee also isRelative()..SH "QFileInfo::QFileInfo ( const QFileInfo & fi )"Constructs a new QFileInfo that is a copy of \fIfi\fR..SH "QFileInfo::~QFileInfo ()"Destroys the QFileInfo and frees its resources..SH "QString QFileInfo::absFilePath () const"Returns the absolute path including the file name..PPThe 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/'..PPThis function returns the same as filePath(), unless isRelative() is TRUE..PPIf the QFileInfo is empty it returns QDir::currentDirPath()..PPThis function can be time consuming under Unix (in the order of milliseconds)..PPSee also isRelative() and filePath()..PPExamples:.)l biff/biff.cpp and fileiconview/qfileiconview.cpp..SH "QString QFileInfo::baseName ( bool complete = FALSE ) const"Returns the base name of the file..PPIf \fIcomplete\fR is FALSE (the default) the base name consists of all characters in the file name up to (but not including) the \fIfirst\fR '.' character..PPIf \fIcomplete\fR is TRUE the base name consists of all characters in the file up to (but not including) the \fIlast\fR '.' character..PPThe path is not included in either case..PPExample:.PP.nf.br QFileInfo fi( "/tmp/archive.tar.gz" );.br QString base = fi.baseName(); // base = "archive".br base = fi.baseName( TRUE ); // base = "archive.tar".br.fi.PPSee also fileName() and extension()..SH "bool QFileInfo::caching () const"Returns TRUE if caching is enabled; otherwise returns FALSE..PPSee also setCaching() and refresh()..SH "bool QFileInfo::convertToAbs ()"Converts the file's path to an absolute path..PPIf it is already absolute, nothing is done..PPSee also filePath() and isRelative()..SH "QDateTime QFileInfo::created () const"Returns the date and time when the file was created..PPOn platforms where this information is not available, returns the same as lastModified()..PPSee also lastModified() and lastRead()..SH "QDir QFileInfo::dir ( bool absPath = FALSE ) const"Returns the file's path as a QDir object..PPIf the QFileInfo is relative and \fIabsPath\fR is FALSE, the QDir will be relative; otherwise it will be absolute.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -