[][src]Struct qt_core::QFileInfo

#[repr(C)]
pub struct QFileInfo { /* fields omitted */ }

The QFileInfo class provides system-independent file information.

C++ class: QFileInfo.

C++ documentation:

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 macOS and iOS), 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.

Note: On NTFS file systems, ownership and permissions checking is disabled by default for performance reasons. To enable it, include the following line:

extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;

Permission checking is then turned on and off by incrementing and decrementing qt_ntfs_permission_lookup by 1.

qt_ntfs_permission_lookup++; // turn checking on qt_ntfs_permission_lookup--; // turn it off again

Methods

impl QFileInfo[src]

pub unsafe fn absolute_dir(&self) -> CppBox<QDir>[src]

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

Calls C++ function: QDir QFileInfo::absoluteDir() const.

C++ documentation:

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

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

pub unsafe fn absolute_file_path(&self) -> CppBox<QString>[src]

Returns an absolute path including the file name.

Calls C++ function: QString QFileInfo::absoluteFilePath() const.

C++ documentation:

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.

Warning: If filePath() is empty the behavior of this function is undefined.

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

pub unsafe fn absolute_path(&self) -> CppBox<QString>[src]

Returns a file's path absolute path. This doesn't include the file name.

Calls C++ function: QString QFileInfo::absolutePath() const.

C++ documentation:

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 filePath() is empty the behavior of this function is undefined.

See also absoluteFilePath(), path(), canonicalPath(), fileName(), and isRelative().

pub unsafe fn base_name(&self) -> CppBox<QString>[src]

Returns the base name of the file without the path.

Calls C++ function: QString QFileInfo::baseName() const.

C++ documentation:

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().

pub unsafe fn birth_time(&self) -> CppBox<QDateTime>[src]

Returns the date and time when the file was created / born.

Calls C++ function: QDateTime QFileInfo::birthTime() const.

C++ documentation:

Returns the date and time when the file was created / born.

If the file birth time is not available, this function returns an invalid QDateTime.

This function was introduced in Qt 5.10.

See also lastModified(), lastRead(), and metadataChangeTime().

This item is available if any(cpp_lib_version="5.11.3", cpp_lib_version="5.12.2", cpp_lib_version="5.13.0", cpp_lib_version="5.14.0").

pub unsafe fn bundle_name(&self) -> CppBox<QString>[src]

Returns the name of the bundle.

Calls C++ function: QString QFileInfo::bundleName() const.

C++ documentation:

Returns the name of the bundle.

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:

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 suffix().

pub unsafe fn caching(&self) -> bool[src]

Returns true if caching is enabled; otherwise returns false.

Calls C++ function: bool QFileInfo::caching() const.

C++ documentation:

Returns true if caching is enabled; otherwise returns false.

See also setCaching() and refresh().

pub unsafe fn canonical_file_path(&self) -> CppBox<QString>[src]

Returns the canonical path including the file name, i.e. an absolute path without symbolic links or redundant "." or ".." elements.

Calls C++ function: QString QFileInfo::canonicalFilePath() const.

C++ documentation:

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().

pub unsafe fn canonical_path(&self) -> CppBox<QString>[src]

Returns the file's path canonical path (excluding the file name), i.e. an absolute path without symbolic links or redundant "." or ".." elements.

Calls C++ function: QString QFileInfo::canonicalPath() const.

C++ documentation:

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().

pub unsafe fn complete_base_name(&self) -> CppBox<QString>[src]

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

Calls C++ function: QString QFileInfo::completeBaseName() const.

C++ documentation:

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().

pub unsafe fn complete_suffix(&self) -> CppBox<QString>[src]

Returns the complete suffix (extension) of the file.

Calls C++ function: QString QFileInfo::completeSuffix() const.

C++ documentation:

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:

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

See also fileName(), suffix(), baseName(), and completeBaseName().

pub unsafe fn copy_from(
    &mut self,
    fileinfo: impl CastInto<Ref<QFileInfo>>
) -> MutRef<QFileInfo>
[src]

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

Calls C++ function: QFileInfo& QFileInfo::operator=(const QFileInfo& fileinfo).

C++ documentation:

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

pub unsafe fn created(&self) -> CppBox<QDateTime>[src]

Returns the date and local time when the file was created.

Calls C++ function: QDateTime QFileInfo::created() const.

C++ documentation:

Returns the date and local 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().

pub unsafe fn dir(&self) -> CppBox<QDir>[src]

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

Calls C++ function: QDir QFileInfo::dir() const.

C++ documentation:

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".

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

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

QFileInfo fileInfo4("."); QFileInfo fileInfo5(".."); QFileInfo fileInfo6("main.cpp");

See also absolutePath(), filePath(), fileName(), isRelative(), and absoluteDir().

pub unsafe fn exists_0a(&self) -> bool[src]

Returns true if the file exists; otherwise returns false.

Calls C++ function: bool QFileInfo::exists() const.

C++ documentation:

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.

pub unsafe fn exists_1a(file: impl CastInto<Ref<QString>>) -> bool[src]

Returns true if the file exists; otherwise returns false.

Calls C++ function: static bool QFileInfo::exists(const QString& file).

C++ documentation:

Returns true if the file exists; otherwise returns false.

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

Note: Using this function is faster than using QFileInfo(file).exists() for file system access.

This function was introduced in Qt 5.2.

pub unsafe fn file_name(&self) -> CppBox<QString>[src]

Returns the name of the file, excluding the path.

Calls C++ function: QString QFileInfo::fileName() const.

C++ documentation:

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 suffix().

pub unsafe fn file_path(&self) -> CppBox<QString>[src]

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

Calls C++ function: QString QFileInfo::filePath() const.

C++ documentation:

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

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

pub unsafe fn file_time(&self, time: FileTime) -> CppBox<QDateTime>[src]

Returns the file time specified by time. If the time cannot be determined, an invalid date time is returned.

Calls C++ function: QDateTime QFileInfo::fileTime(QFileDevice::FileTime time) const.

C++ documentation:

Returns the file time specified by time. If the time cannot be determined, an invalid date time is returned.

This function was introduced in Qt 5.10.

See also QFile::FileTime and QDateTime::isValid().

This item is available if any(cpp_lib_version="5.11.3", cpp_lib_version="5.12.2", cpp_lib_version="5.13.0", cpp_lib_version="5.14.0").

pub unsafe fn group(&self) -> CppBox<QString>[src]

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.

Calls C++ function: QString QFileInfo::group() const.

C++ documentation:

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().

pub unsafe fn group_id(&self) -> c_uint[src]

Returns the id of the group the file belongs to.

Calls C++ function: unsigned int QFileInfo::groupId() const.

C++ documentation:

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().

pub unsafe fn is_absolute(&self) -> bool[src]

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

Calls C++ function: bool QFileInfo::isAbsolute() const.

C++ documentation:

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

See also isRelative().

pub unsafe fn is_bundle(&self) -> bool[src]

Returns true if this object points to a bundle or to a symbolic link to a bundle on macOS and iOS; otherwise returns false.

Calls C++ function: bool QFileInfo::isBundle() const.

C++ documentation:

Returns true if this object points to a bundle or to a symbolic link to a bundle on macOS and iOS; otherwise returns false.

This function was introduced in Qt 4.3.

See also isDir(), isSymLink(), and isFile().

pub unsafe fn is_dir(&self) -> bool[src]

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

Calls C++ function: bool QFileInfo::isDir() const.

C++ documentation:

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().

pub unsafe fn is_executable(&self) -> bool[src]

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

Calls C++ function: bool QFileInfo::isExecutable() const.

C++ documentation:

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

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

pub unsafe fn is_file(&self) -> bool[src]

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.

Calls C++ function: bool QFileInfo::isFile() const.

C++ documentation:

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().

pub unsafe fn is_hidden(&self) -> bool[src]

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

Calls C++ function: bool QFileInfo::isHidden() const.

C++ documentation:

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.

pub unsafe fn is_native_path(&self) -> bool[src]

Returns 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 the Qt Resource System.

Calls C++ function: bool QFileInfo::isNativePath() const.

C++ documentation:

Returns 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 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.

This function was introduced in Qt 5.0.

See also QDir::toNativeSeparators(), QFile::encodeName(), filePath(), absoluteFilePath(), and canonicalFilePath().

pub unsafe fn is_readable(&self) -> bool[src]

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

Calls C++ function: bool QFileInfo::isReadable() const.

C++ documentation:

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

Note: If the NTFS permissions check has not been enabled, the result on Windows will merely reflect whether the file exists.

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

pub unsafe fn is_relative(&self) -> bool[src]

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 "/").

Calls C++ function: bool QFileInfo::isRelative() const.

C++ documentation:

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().

pub unsafe fn is_root(&self) -> bool[src]

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.

Calls C++ function: bool QFileInfo::isRoot() const.

C++ documentation:

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.

pub unsafe fn is_shortcut(&self) -> bool[src]

Returns true if this object points to a shortcut; otherwise returns false.

Calls C++ function: bool QFileInfo::isShortcut() const.

C++ documentation:

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.

Note: Even if a shortcut (broken shortcut) points to a non existing file, isShortcut() returns true.

See also isFile(), isDir(), isSymbolicLink(), and symLinkTarget().

This item is available if cpp_lib_version="5.14.0".

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

Calls C++ function: bool QFileInfo::isSymLink() const.

C++ documentation:

Returns true if this object points to a symbolic link; 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 link's target.

In addition, true will be returned for shortcuts (*.lnk files) on Windows. Opening those will open 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().

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

Calls C++ function: bool QFileInfo::isSymbolicLink() const.

C++ documentation:

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 link's target.

In contrast to isSymLink(), false will be returned for shortcuts (*.lnk files) on Windows. Use QFileInfo::isShortcut() instead.

Note: If the symlink points to a non existing file, exists() returns false.

See also isFile(), isDir(), isShortcut(), and symLinkTarget().

This item is available if cpp_lib_version="5.14.0".

pub unsafe fn is_writable(&self) -> bool[src]

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

Calls C++ function: bool QFileInfo::isWritable() const.

C++ documentation:

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

Note: If the NTFS permissions check has not been enabled, the result on Windows will merely reflect whether the file is marked as Read Only.

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

pub unsafe fn last_modified(&self) -> CppBox<QDateTime>[src]

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

Calls C++ function: QDateTime QFileInfo::lastModified() const.

C++ documentation:

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

See also created() and lastRead().

pub unsafe fn last_read(&self) -> CppBox<QDateTime>[src]

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

Calls C++ function: QDateTime QFileInfo::lastRead() const.

C++ documentation:

Returns the date and local 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().

pub unsafe fn make_absolute(&mut self) -> bool[src]

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.

Calls C++ function: bool QFileInfo::makeAbsolute().

C++ documentation:

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().

pub unsafe fn metadata_change_time(&self) -> CppBox<QDateTime>[src]

Returns the date and time when the file metadata was changed. A metadata 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).

Calls C++ function: QDateTime QFileInfo::metadataChangeTime() const.

C++ documentation:

Returns the date and time when the file metadata was changed. A metadata 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).

This function was introduced in Qt 5.10.

See also lastModified() and lastRead().

This item is available if any(cpp_lib_version="5.11.3", cpp_lib_version="5.12.2", cpp_lib_version="5.13.0", cpp_lib_version="5.14.0").

pub unsafe fn new() -> CppBox<QFileInfo>[src]

Constructs an empty QFileInfo object.

Calls C++ function: [constructor] void QFileInfo::QFileInfo().

C++ documentation:

Constructs an empty QFileInfo object.

Note that an empty QFileInfo object contain no file reference.

See also setFile().

pub unsafe fn from_q_string(
    file: impl CastInto<Ref<QString>>
) -> CppBox<QFileInfo>
[src]

Constructs a new QFileInfo that gives information about the given file. The file can also include an absolute or relative path.

Calls C++ function: [constructor] void QFileInfo::QFileInfo(const QString& file).

C++ documentation:

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().

pub unsafe fn from_q_file(file: impl CastInto<Ref<QFile>>) -> CppBox<QFileInfo>[src]

Constructs a new QFileInfo that gives information about file file.

Calls C++ function: [constructor] void QFileInfo::QFileInfo(const QFile& file).

C++ documentation:

Constructs a new QFileInfo that gives information about file file.

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

See also isRelative().

pub unsafe fn from_q_dir_q_string(
    dir: impl CastInto<Ref<QDir>>,
    file: impl CastInto<Ref<QString>>
) -> CppBox<QFileInfo>
[src]

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

Calls C++ function: [constructor] void QFileInfo::QFileInfo(const QDir& dir, const QString& file).

C++ documentation:

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

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

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

See also isRelative().

pub unsafe fn new_copy(
    fileinfo: impl CastInto<Ref<QFileInfo>>
) -> CppBox<QFileInfo>
[src]

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

Calls C++ function: [constructor] void QFileInfo::QFileInfo(const QFileInfo& fileinfo).

C++ documentation:

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

pub unsafe fn owner(&self) -> CppBox<QString>[src]

Returns the owner of the file. On systems where files do not have owners, or if an error occurs, an empty string is returned.

Calls C++ function: QString QFileInfo::owner() const.

C++ documentation:

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 NTFS permissions check has been enabled.

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

pub unsafe fn owner_id(&self) -> c_uint[src]

Returns the id of the owner of the file.

Calls C++ function: unsigned int QFileInfo::ownerId() const.

C++ documentation:

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().

pub unsafe fn path(&self) -> CppBox<QString>[src]

Returns the file's path. This doesn't include the file name.

Calls C++ function: QString QFileInfo::path() const.

C++ documentation:

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().

pub unsafe fn permission(&self, permissions: QFlags<Permission>) -> bool[src]

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

Calls C++ function: bool QFileInfo::permission(QFlags<QFileDevice::Permission> permissions) const.

C++ documentation:

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.

Note: The result might be inaccurate on Windows if the NTFS permissions check has not been enabled.

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().

pub unsafe fn permissions(&self) -> QFlags<Permission>[src]

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

Calls C++ function: QFlags<QFileDevice::Permission> QFileInfo::permissions() const.

C++ documentation:

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

Note: The result might be inaccurate on Windows if the NTFS permissions check has not been enabled.

Use symLinkTarget() instead.

Calls C++ function: QString QFileInfo::readLink() const.

C++ documentation:

Use symLinkTarget() instead.

pub unsafe fn refresh(&mut self)[src]

Refreshes the information about the file, i.e. reads in information from the file system the next time a cached property is fetched.

Calls C++ function: void QFileInfo::refresh().

C++ documentation:

Refreshes the information about the file, i.e. reads in information from the file system the next time a cached property is fetched.

pub unsafe fn set_caching(&mut self, on: bool)[src]

If enable is true, enables caching of file information. If enable is false caching is disabled.

Calls C++ function: void QFileInfo::setCaching(bool on).

C++ documentation:

If enable is true, enables caching of file information. If enable is false caching is disabled.

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

Caching is enabled by default.

See also refresh() and caching().

pub unsafe fn set_file_q_string(&mut self, file: impl CastInto<Ref<QString>>)[src]

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

Calls C++ function: void QFileInfo::setFile(const QString& file).

C++ documentation:

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().

pub unsafe fn set_file_q_file(&mut self, file: impl CastInto<Ref<QFile>>)[src]

This is an overloaded function.

Calls C++ function: void QFileInfo::setFile(const QFile& file).

C++ documentation:

This is an overloaded function.

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.

See also isRelative().

pub unsafe fn set_file_q_dir_q_string(
    &mut self,
    dir: impl CastInto<Ref<QDir>>,
    file: impl CastInto<Ref<QString>>
)
[src]

This is an overloaded function.

Calls C++ function: void QFileInfo::setFile(const QDir& dir, const QString& file).

C++ documentation:

This is an overloaded function.

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.

See also isRelative().

pub unsafe fn size(&self) -> i64[src]

Returns the file size in bytes. If the file does not exist or cannot be fetched, 0 is returned.

Calls C++ function: qint64 QFileInfo::size() const.

C++ documentation:

Returns the file size in bytes. If the file does not exist or cannot be fetched, 0 is returned.

See also exists().

pub unsafe fn suffix(&self) -> CppBox<QString>[src]

Returns the suffix (extension) of the file.

Calls C++ function: QString QFileInfo::suffix() const.

C++ documentation:

Returns the suffix (extension) 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().

pub unsafe fn swap(&mut self, other: impl CastInto<MutRef<QFileInfo>>)[src]

Swaps this file info with other. This function is very fast and never fails.

Calls C++ function: void QFileInfo::swap(QFileInfo& other).

C++ documentation:

Swaps this file info with other. This function is very fast and never fails.

This function was introduced in Qt 5.0.

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.

Calls C++ function: QString QFileInfo::symLinkTarget() const.

C++ documentation:

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.

This function was introduced in Qt 4.2.

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

Trait Implementations

impl CppDeletable for QFileInfo[src]

unsafe fn delete(&mut self)[src]

Destroys the QFileInfo and frees its resources.

Calls C++ function: [destructor] void QFileInfo::~QFileInfo().

C++ documentation:

Destroys the QFileInfo and frees its resources.

impl PartialEq<Ref<QFileInfo>> for QFileInfo[src]

fn eq(&self, fileinfo: &Ref<QFileInfo>) -> bool[src]

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

Calls C++ function: bool QFileInfo::operator==(const QFileInfo& fileinfo) const.

C++ documentation:

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.

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!=().

impl Size for QFileInfo[src]

unsafe fn size(&self) -> usize[src]

Returns the file size in bytes. If the file does not exist or cannot be fetched, 0 is returned.

Calls C++ function: qint64 QFileInfo::size() const.

C++ documentation:

Returns the file size in bytes. If the file does not exist or cannot be fetched, 0 is returned.

See also exists().

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.