Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QFileInfo class provides system-independent file information. More...
Public Member Functions | |
override bool | Equals (object o) |
override int | GetHashCode () |
QFileInfo () | |
| |
QFileInfo (QFile file) | |
| |
QFileInfo (QFileInfo fileinfo) | |
| |
QFileInfo (QDir dir, string file) | |
| |
QFileInfo (string file) | |
| |
virtual void | CreateProxy () |
new QDir | AbsoluteDir () |
| |
new string | AbsoluteFilePath () |
| |
new string | AbsolutePath () |
| |
new string | BaseName () |
| |
new string | BundleName () |
| |
new string | CanonicalFilePath () |
| |
new string | CanonicalPath () |
| |
new string | CompleteBaseName () |
| |
new string | CompleteSuffix () |
| |
new QDateTime | Created () |
| |
new void | Detach () |
new QDir | Dir () |
| |
new bool | Exists () |
| |
new string | FileName () |
| |
new string | FilePath () |
| |
new string | Group () |
| |
new uint | GroupId () |
| |
new bool | IsAbsolute () |
| |
new bool | IsBundle () |
| |
new bool | IsDir () |
| |
new bool | IsExecutable () |
| |
new bool | IsFile () |
| |
new bool | IsHidden () |
| |
new bool | IsReadable () |
| |
new bool | IsRelative () |
| |
new bool | IsRoot () |
| |
new bool | IsSymLink () |
| |
new bool | IsWritable () |
| |
new QDateTime | LastModified () |
| |
new QDateTime | LastRead () |
| |
new bool | MakeAbsolute () |
| |
new string | Owner () |
| |
new uint | OwnerId () |
| |
new string | Path () |
| |
new bool | Permission (QFile.Permission permissions) |
| |
new QFile.Permission | Permissions () |
| |
new string | ReadLink () |
| |
new void | Refresh () |
| |
new void | SetFile (QFile file) |
| |
new void | SetFile (QDir dir, string file) |
| |
new void | SetFile (string file) |
| |
new long | Size () |
| |
new string | Suffix () |
| |
new string | SymLinkTarget () |
| |
new void | Dispose () |
Static Public Member Functions | |
static bool | operator!= (QFileInfo arg1, QFileInfo arg2) |
| |
static bool | operator== (QFileInfo arg1, QFileInfo arg2) |
| |
Protected Member Functions | |
QFileInfo (System.Type dummy) | |
Protected Attributes | |
SmokeInvocation | interceptor |
Properties | |
new bool | Caching [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
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.
A QFileInfo can point to a file with either a relative or an absolute file path. Absolute file paths begin with the directory separator "/" (or with a drive specification on Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current working directory. An example of an absolute path is the string "/tmp/quartz". A relative path might look like "src/fatlib". You can use the function isRelative() to check whether a QFileInfo is using a relative or an absolute file path. You can call the function makeAbsolute() to convert a relative QFileInfo's path to an absolute path.
The file that the QFileInfo works on is set in the constructor or later with setFile(). Use exists() to see if the file exists and size() to get its size.
The file's type is obtained with isFile(), isDir() and isSymLink(). The symLinkTarget() function provides the name of the file the symlink points to.
On Unix (including Mac OS X), the symlink has the same size() has the file it points to, because Unix handles symlinks transparently; similarly, opening a symlink using QFile effectively opens the link's target. For example:
#ifdef Q_OS_UNIX
QFileInfo info1("/home/bob/bin/untabify");
info1.isSymLink(); // returns true
info1.absoluteFilePath(); // returns "/home/bob/bin/untabify"
info1.size(); // returns 56201
info1.symLinkTarget(); // returns "/opt/pretty++/bin/untabify"
QFileInfo info2(info1.symLinkTarget());
info2.isSymLink(); // returns false
info2.absoluteFilePath(); // returns "/opt/pretty++/bin/untabify"
info2.size(); // returns 56201
#endif
On Windows, symlinks (shortcuts) are .lnk files. The reported size() is that of the symlink (not the link's target), and opening a symlink using QFile opens the .lnk file. For example:
#ifdef Q_OS_WIN
QFileInfo info1("C:\\Documents and Settings\\Bob\\untabify.lnk");
info1.isSymLink(); // returns true
info1.absoluteFilePath(); // returns "C:/Documents and Settings/Bob/untabify.lnk"
info1.size(); // returns 743
info1.symLinkTarget(); // returns "C:/Pretty++/untabify"
QFileInfo info2(info1.symLinkTarget());
info2.isSymLink(); // returns false
info2.absoluteFilePath(); // returns "C:/Pretty++/untabify"
info2.size(); // returns 63942
#endif
Elements of the file's name can be extracted with path() and fileName(). The fileName()'s parts can be extracted with baseName(), suffix() or completeSuffix(). QFileInfo objects to directories created by Qt classes will not have a trailing file separator. If you wish to use trailing separators in your own file info objects, just append one to the file name given to the constructors or setFile().
The file's dates are returned by created(), lastModified() and lastRead(). Information about the file's access permissions is obtained with isReadable(), isWritable() and isExecutable(). The file's ownership is available from owner(), ownerId(), group() and groupId(). You can examine a file's permissions and ownership in a single statement using the permission() function.
Performance Issues
Some of QFileInfo's functions query the file system, but for performance reasons, some functions only operate on the file name itself. For example: To return the absolute path of a relative file name, absolutePath() has to query the file system. The path() function, however, can work on the file name directly, and so it is faster.
Note: To speed up performance, QFileInfo caches information about the file.
To speed up performance, QFileInfo caches information about the file. Because files can be changed by other users or programs, or even by other parts of the same program, there is a function that refreshes the file information: refresh(). If you want to switch off a QFileInfo's caching and force it to access the file system every time you request information from it call setCaching(false).
|
protected |
QtCore.QFileInfo.QFileInfo | ( | ) |
QtCore.QFileInfo.QFileInfo | ( | QFile | file | ) |
QtCore.QFileInfo.QFileInfo | ( | QFileInfo | fileinfo | ) |
Constructs a new QFileInfo that is a copy of the given fileinfo.
QtCore.QFileInfo.QFileInfo | ( | QDir | dir, |
string | file | ||
) |
QtCore.QFileInfo.QFileInfo | ( | string | file | ) |
Constructs a new QFileInfo that gives information about the given file. The file can also include an absolute or relative path.
See also setFile(), isRelative(), QDir::setCurrent(), and QDir::isRelativePath().
new QDir QtCore.QFileInfo.AbsoluteDir | ( | ) |
Returns the file's absolute path as a QDir object.
See also dir(), filePath(), fileName(), and isRelative().
new string QtCore.QFileInfo.AbsoluteFilePath | ( | ) |
Returns an absolute path including the file name.
The absolute path name consists of the full path and the file name. On Unix this will always begin with the root, '/', directory. On Windows this will always begin 'D:/' where D is a drive letter, except for network shares that are not mapped to a drive letter, in which case the path will begin '//sharename/'. QFileInfo will uppercase drive letters. Note that QDir does not do this. The code snippet below shows this.
QFileInfo fi("c:/temp/foo"); => fi.absoluteFilePath() => "C:/temp/foo"
This function returns the same as filePath(), unless isRelative() is true. In contrast to canonicalFilePath(), symbolic links or redundant "." or ".." elements are not necessarily removed.
If the QFileInfo is empty it returns QDir::currentPath().
See also filePath(), canonicalFilePath(), and isRelative().
new string QtCore.QFileInfo.AbsolutePath | ( | ) |
Returns a file's path absolute path. This doesn't include the file name.
On Unix the absolute path will always begin with the root, '/', directory. On Windows this will always begin 'D:/' where D is a drive letter, except for network shares that are not mapped to a drive letter, in which case the path will begin '//sharename/'.
In contrast to canonicalPath() symbolic links or redundant "." or ".." elements are not necessarily removed.
Warning: If the QFileInfo object was created with an empty QString, the behavior of this function is undefined.
See also absoluteFilePath(), path(), canonicalPath(), fileName(), and isRelative().
new string QtCore.QFileInfo.BaseName | ( | ) |
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:
QFileInfo fi("/tmp/archive.tar.gz");
QString base = fi.baseName(); // base = "archive"
The base name of a file is computed equally on all platforms, independent of file naming conventions (e.g., ".bashrc" on Unix has an empty base name, and the suffix is "bashrc").
See also fileName(), suffix(), completeSuffix(), and completeBaseName().
new string QtCore.QFileInfo.BundleName | ( | ) |
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:
QFileInfo fi("/Applications/Safari.app");
QString bundle = fi.bundleName(); // name = "Safari"
This function was introduced in Qt 4.3.
See also isBundle(), filePath(), baseName(), and extension().
new string QtCore.QFileInfo.CanonicalFilePath | ( | ) |
Returns the canonical path including the file name, i.e. an absolute path without symbolic links or redundant "." or ".." elements.
If the file does not exist, canonicalFilePath() returns an empty string.
See also filePath(), absoluteFilePath(), and dir().
new string QtCore.QFileInfo.CanonicalPath | ( | ) |
Returns the file's path canonical path (excluding the file name), i.e. an absolute path without symbolic links or redundant "." or ".." elements.
If the file does not exist, canonicalPath() returns an empty string.
See also path() and absolutePath().
new string QtCore.QFileInfo.CompleteBaseName | ( | ) |
Returns the complete base name of the file without the path.
The complete base name consists of all characters in the file up to (but not including) the last '.' character.
Example:
QFileInfo fi("/tmp/archive.tar.gz");
QString base = fi.completeBaseName(); // base = "archive.tar"
See also fileName(), suffix(), completeSuffix(), and baseName().
new string QtCore.QFileInfo.CompleteSuffix | ( | ) |
Returns the complete suffix of the file.
The complete suffix consists of all characters in the file after (but not including) the first '.'.
Example:
QFileInfo fi("/tmp/archive.tar.gz");
QString ext = fi.completeSuffix(); // ext = "tar.gz"
See also fileName(), suffix(), baseName(), and completeBaseName().
new QDateTime QtCore.QFileInfo.Created | ( | ) |
Returns the date and time when the file was created.
On most Unix systems, this function returns the time of the last status change. A status change occurs when the file is created, but it also occurs whenever the user writes or sets inode information (for example, changing the file permissions).
If neither creation time nor "last status change" time are not available, returns the same as lastModified().
See also lastModified() and lastRead().
|
virtual |
new void QtCore.QFileInfo.Detach | ( | ) |
new QDir QtCore.QFileInfo.Dir | ( | ) |
Returns the path of the object's parent directory as a QDir object.
Note: The QDir returned always corresponds to the object's parent directory, even if the QFileInfo represents a directory.
For each of the following, dir() returns a QDir for "~/examples/191697".
QFileInfo fileInfo1("~/examples/191697/.");
QFileInfo fileInfo2("~/examples/191697/..");
QFileInfo fileInfo3("~/examples/191697/main.cpp");
For each of the following, dir() returns a QDir for ".".
QFileInfo fileInfo4(".");
QFileInfo fileInfo5("..");
QFileInfo fileInfo6("main.cpp");
See also absolutePath(), filePath(), fileName(), isRelative(), and absoluteDir().
new void QtCore.QFileInfo.Dispose | ( | ) |
override bool QtCore.QFileInfo.Equals | ( | object | o | ) |
new bool QtCore.QFileInfo.Exists | ( | ) |
Returns true if the file exists; otherwise returns false.
Note: If the file is a symlink that points to a non existing file, false is returned.
new string QtCore.QFileInfo.FileName | ( | ) |
Returns the name of the file, excluding the path.
Example:
QFileInfo fi("/tmp/archive.tar.gz");
QString name = fi.fileName(); // name = "archive.tar.gz"
Note that, if this QFileInfo object is given a path ending in a slash, the name of the file is considered empty.
See also isRelative(), filePath(), baseName(), and extension().
new string QtCore.QFileInfo.FilePath | ( | ) |
Returns the file name, including the path (which may be absolute or relative).
See also absoluteFilePath(), canonicalFilePath(), and isRelative().
override int QtCore.QFileInfo.GetHashCode | ( | ) |
new string QtCore.QFileInfo.Group | ( | ) |
Returns the group of the file. On Windows, on systems where files do not have groups, or if an error occurs, an empty string is returned.
This function can be time consuming under Unix (in the order of milliseconds).
See also groupId(), owner(), and ownerId().
new uint QtCore.QFileInfo.GroupId | ( | ) |
Returns the id of the group the file belongs to.
On Windows and on systems where files do not have groups this function always returns (uint) -2.
See also group(), owner(), and ownerId().
new bool QtCore.QFileInfo.IsAbsolute | ( | ) |
Returns true if the file path name is absolute, otherwise returns false if the path is relative.
See also isRelative().
new bool QtCore.QFileInfo.IsBundle | ( | ) |
Returns true if this object points to a bundle or to a symbolic link to a bundle on Mac OS X; otherwise returns false.
This function was introduced in Qt 4.3.
See also isDir(), isSymLink(), and isFile().
new bool QtCore.QFileInfo.IsDir | ( | ) |
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise returns false.
See also isFile(), isSymLink(), and isBundle().
new bool QtCore.QFileInfo.IsExecutable | ( | ) |
Returns true if the file is executable; otherwise returns false.
See also isReadable(), isWritable(), and permission().
new bool QtCore.QFileInfo.IsFile | ( | ) |
Returns true if this object points to a file or to a symbolic link to a file. Returns false if the object points to something which isn't a file, such as a directory.
See also isDir(), isSymLink(), and isBundle().
new bool QtCore.QFileInfo.IsHidden | ( | ) |
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.
new bool QtCore.QFileInfo.IsReadable | ( | ) |
Returns true if the user can read the file; otherwise returns false.
See also isWritable(), isExecutable(), and permission().
new bool QtCore.QFileInfo.IsRelative | ( | ) |
Returns true if the file path name is relative, otherwise returns false if the path is absolute (e.g. under Unix a path is absolute if it begins with a "/").
See also isAbsolute().
new bool QtCore.QFileInfo.IsRoot | ( | ) |
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.
new bool QtCore.QFileInfo.IsSymLink | ( | ) |
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:
QFileInfo info(fileName);
if (info.isSymLink())
fileName = info.symLinkTarget();
Note: If the symlink points to a non existing file, exists() returns false.
See also isFile(), isDir(), and symLinkTarget().
new bool QtCore.QFileInfo.IsWritable | ( | ) |
Returns true if the user can write to the file; otherwise returns false.
See also isReadable(), isExecutable(), and permission().
new QDateTime QtCore.QFileInfo.LastModified | ( | ) |
Returns the date and time when the file was last modified.
See also created() and lastRead().
new QDateTime QtCore.QFileInfo.LastRead | ( | ) |
Returns the date and time when the file was last read (accessed).
On platforms where this information is not available, returns the same as lastModified().
See also created() and lastModified().
new bool QtCore.QFileInfo.MakeAbsolute | ( | ) |
Converts the file's path to an absolute path if it is not already in that form. Returns true to indicate that the path was converted; otherwise returns false to indicate that the path was already absolute.
See also filePath() and isRelative().
Returns true if this QFileInfo object refers to a different file than the one specified by fileinfo; otherwise returns false.
See also operator==().
Returns true if this QFileInfo object refers to a file in the same location as fileinfo; otherwise returns false.
Note that the result of comparing two empty QFileInfo objects, containing no file references, is undefined.
Warning: This will not compare two different symbolic links pointing to the same file.
Warning: Long and short file names that refer to the same file on Windows are treated as if they referred to different files.
See also operator!=().
new string QtCore.QFileInfo.Owner | ( | ) |
Returns the owner of the file. On systems where files do not have owners, or if an error occurs, an empty string is returned.
This function can be time consuming under Unix (in the order of milliseconds).
See also ownerId(), group(), and groupId().
new uint QtCore.QFileInfo.OwnerId | ( | ) |
Returns the id of the owner of the file.
On Windows and on systems where files do not have owners this function returns ((uint) -2).
See also owner(), group(), and groupId().
new string QtCore.QFileInfo.Path | ( | ) |
Returns the file's path. This doesn't include the file name.
Note that, if this QFileInfo object is given a path ending in a slash, the name of the file is considered empty and this function will return the entire path.
See also filePath(), absolutePath(), canonicalPath(), dir(), fileName(), and isRelative().
new bool QtCore.QFileInfo.Permission | ( | QFile.Permission | permissions | ) |
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:
QFileInfo fi("/tmp/archive.tar.gz");
if (fi.permission(QFile::WriteUser | QFile::ReadGroup))
qWarning("I can change the file; my group can read the file");
if (fi.permission(QFile::WriteGroup | QFile::WriteOther))
qWarning("The group or others can change the file");
See also isReadable(), isWritable(), and isExecutable().
new QFile.Permission QtCore.QFileInfo.Permissions | ( | ) |
Returns the complete OR-ed together combination of QFile::Permissions for the file.
new string QtCore.QFileInfo.ReadLink | ( | ) |
Use symLinkTarget() instead.
new void QtCore.QFileInfo.Refresh | ( | ) |
Refreshes the information about the file, i.e. reads in information from the file system the next time a cached property is fetched.
Note: On Windows CE, there might be a delay for the file system driver to detect changes on the file.
new void QtCore.QFileInfo.SetFile | ( | QFile | file | ) |
new void QtCore.QFileInfo.SetFile | ( | QDir | dir, |
string | file | ||
) |
new void QtCore.QFileInfo.SetFile | ( | string | file | ) |
Sets the file that the QFileInfo provides information about to file.
The file can also include an absolute or relative file path. Absolute paths begin with the directory separator (e.g. "/" under Unix) or a drive specification (under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory.
Example:
QString absolute = "/local/bin";
QString relative = "local/bin";
QFileInfo absFile(absolute);
QFileInfo relFile(relative);
QDir::setCurrent(QDir::rootPath());
// absFile and relFile now point to the same file
QDir::setCurrent("/tmp");
// absFile now points to "/local/bin",
// while relFile points to "/tmp/local/bin"
See also isFile(), isRelative(), QDir::setCurrent(), and QDir::isRelativePath().
new long QtCore.QFileInfo.Size | ( | ) |
Returns the file size in bytes. If the file does not exist or cannot be fetched, 0 is returned.
See also exists().
new string QtCore.QFileInfo.Suffix | ( | ) |
Returns the suffix of the file.
The suffix consists of all characters in the file after (but not including) the last '.'.
Example:
QFileInfo fi("/tmp/archive.tar.gz");
QString ext = fi.suffix(); // ext = "gz"
The suffix of a file is computed equally on all platforms, independent of file naming conventions (e.g., ".bashrc" on Unix has an empty base name, and the suffix is "bashrc").
See also fileName(), completeSuffix(), baseName(), and completeBaseName().
new string QtCore.QFileInfo.SymLinkTarget | ( | ) |
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.
This function was introduced in Qt 4.2.
See also exists(), isSymLink(), isDir(), and isFile().
|
protected |
|
getset |
Returns true if caching is enabled; otherwise returns false.
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.
|
getset |