[][src]Struct qt_core::QStorageInfo

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

Provides information about currently mounted storage and drives.

C++ class: QStorageInfo.

C++ documentation:

Provides information about currently mounted storage and drives.

Allows retrieving information about the volume's space, its mount point, label, and filesystem name.

You can create an instance of QStorageInfo by passing the path to the volume's mount point as a constructor parameter, or you can set it using the setPath() method. The static mountedVolumes() method can be used to get the list of all mounted filesystems.

QStorageInfo always caches the retrieved information, but you can call refresh() to invalidate the cache.

The following example retrieves the most common information about the root volume of the system, and prints information about it.

QStorageInfo storage = QStorageInfo::root();

qDebug() << storage.rootPath(); if (storage.isReadOnly()) qDebug() << "isReadOnly:" << storage.isReadOnly();

qDebug() << "name:" << storage.name(); qDebug() << "fileSystemType:" << storage.fileSystemType(); qDebug() << "size:" << storage.bytesTotal()/1000/1000 << "MB"; qDebug() << "availableSize:" << storage.bytesAvailable()/1000/1000 << "MB";

Methods

impl QStorageInfo[src]

pub unsafe fn block_size(&self) -> c_int[src]

Returns the optimal transfer block size for this filesystem.

Calls C++ function: int QStorageInfo::blockSize() const.

C++ documentation:

Returns the optimal transfer block size for this filesystem.

Returns -1 if QStorageInfo could not determine the size or if the QStorageInfo object is not valid.

This function was introduced in Qt 5.6.

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

Returns the size (in bytes) available for the current user. It returns the total size available if the user is the root user or a system administrator.

Calls C++ function: qint64 QStorageInfo::bytesAvailable() const.

C++ documentation:

Returns the size (in bytes) available for the current user. It returns the total size available if the user is the root user or a system administrator.

This size can be less than or equal to the free size returned by bytesFree() function.

Returns -1 if QStorageInfo object is not valid.

See also bytesTotal() and bytesFree().

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

Returns the number of free bytes in a volume. Note that if there are quotas on the filesystem, this value can be larger than the value returned by bytesAvailable().

Calls C++ function: qint64 QStorageInfo::bytesFree() const.

C++ documentation:

Returns the number of free bytes in a volume. Note that if there are quotas on the filesystem, this value can be larger than the value returned by bytesAvailable().

Returns -1 if QStorageInfo object is not valid.

See also bytesTotal() and bytesAvailable().

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

Returns the total volume size in bytes.

Calls C++ function: qint64 QStorageInfo::bytesTotal() const.

C++ documentation:

Returns the total volume size in bytes.

Returns -1 if QStorageInfo object is not valid.

See also bytesFree() and bytesAvailable().

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

Makes a copy of the QStorageInfo object other and assigns it to this QStorageInfo object.

Calls C++ function: QStorageInfo& QStorageInfo::operator=(const QStorageInfo& other).

C++ documentation:

Makes a copy of the QStorageInfo object other and assigns it to this QStorageInfo object.

pub unsafe fn device(&self) -> CppBox<QByteArray>[src]

Returns the device for this volume.

Calls C++ function: QByteArray QStorageInfo::device() const.

C++ documentation:

Returns the device for this volume.

For example, on Unix filesystems (including macOS), this returns the devpath like /dev/sda0 for local storages. On Windows, it returns the UNC path starting with \\\\?\\ for local storages (in other words, the volume GUID).

See also rootPath() and subvolume().

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

Returns the volume's name, if available, or the root path if not.

Calls C++ function: QString QStorageInfo::displayName() const.

C++ documentation:

Returns the volume's name, if available, or the root path if not.

pub unsafe fn file_system_type(&self) -> CppBox<QByteArray>[src]

Returns the type name of the filesystem.

Calls C++ function: QByteArray QStorageInfo::fileSystemType() const.

C++ documentation:

Returns the type name of the filesystem.

This is a platform-dependent function, and filesystem names can vary between different operating systems. For example, on Windows filesystems they can be named NTFS, and on Linux they can be named ntfs-3g or fuseblk.

See also name().

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

Returns true if the current filesystem is protected from writing; false otherwise.

Calls C++ function: bool QStorageInfo::isReadOnly() const.

C++ documentation:

Returns true if the current filesystem is protected from writing; false otherwise.

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

Returns true if the current filesystem is ready to work; false otherwise. For example, false is returned if the CD volume is not inserted.

Calls C++ function: bool QStorageInfo::isReady() const.

C++ documentation:

Returns true if the current filesystem is ready to work; false otherwise. For example, false is returned if the CD volume is not inserted.

Note that fileSystemType(), name(), bytesTotal(), bytesFree(), and bytesAvailable() will return invalid data until the volume is ready.

See also isValid().

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

Returns true if this QStorageInfo represents the system root volume; false otherwise.

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

C++ documentation:

Returns true if this QStorageInfo represents the system root volume; false otherwise.

On Unix filesystems, the root volume is a volume mounted on /. On Windows, the root volume is the volume where the OS is installed.

See also root().

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

Returns true if the QStorageInfo specified by rootPath exists and is mounted correctly.

Calls C++ function: bool QStorageInfo::isValid() const.

C++ documentation:

Returns true if the QStorageInfo specified by rootPath exists and is mounted correctly.

See also isReady().

pub unsafe fn mounted_volumes() -> CppBox<QListOfQStorageInfo>[src]

Returns the list of QStorageInfo objects that corresponds to the list of currently mounted filesystems.

Calls C++ function: static QList<QStorageInfo> QStorageInfo::mountedVolumes().

C++ documentation:

Returns the list of QStorageInfo objects that corresponds to the list of currently mounted filesystems.

On Windows, this returns the drives visible in the My Computer folder. On Unix operating systems, it returns the list of all mounted filesystems (except for pseudo filesystems).

Returns all currently mounted filesystems by default.

The example shows how to retrieve all available filesystems, skipping read-only ones.

foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) { if (storage.isValid() && storage.isReady()) { if (!storage.isReadOnly()) { // ... } } }

See also root().

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

Returns the human-readable name of a filesystem, usually called label.

Calls C++ function: QString QStorageInfo::name() const.

C++ documentation:

Returns the human-readable name of a filesystem, usually called label.

Not all filesystems support this feature. In this case, the value returned by this method could be empty. An empty string is returned if the file system does not support labels, or if no label is set.

On Linux, retrieving the volume's label requires udev to be present in the system.

See also fileSystemType().

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

Constructs an empty QStorageInfo object.

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

C++ documentation:

Constructs an empty QStorageInfo object.

Objects created with the default constructor will be invalid and therefore not ready for use.

See also setPath(), isReady(), and isValid().

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

Constructs a new QStorageInfo object that gives information about the volume mounted at path.

Calls C++ function: [constructor] void QStorageInfo::QStorageInfo(const QString& path).

C++ documentation:

Constructs a new QStorageInfo object that gives information about the volume mounted at path.

If you pass a directory or file, the QStorageInfo object will refer to the volume where this directory or file is located. You can check if the created object is correct using the isValid() method.

The following example shows how to get the volume on which the application is located. It is recommended to always check that the volume is ready and valid.

QStorageInfo storage(qApp->applicationDirPath()); if (storage.isValid() && storage.isReady()) { // ... }

See also setPath().

pub unsafe fn from_q_dir(dir: impl CastInto<Ref<QDir>>) -> CppBox<QStorageInfo>[src]

Constructs a new QStorageInfo object that gives information about the volume containing the dir folder.

Calls C++ function: [constructor] void QStorageInfo::QStorageInfo(const QDir& dir).

C++ documentation:

Constructs a new QStorageInfo object that gives information about the volume containing the dir folder.

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

Constructs a new QStorageInfo object that is a copy of the other QStorageInfo object.

Calls C++ function: [constructor] void QStorageInfo::QStorageInfo(const QStorageInfo& other).

C++ documentation:

Constructs a new QStorageInfo object that is a copy of the other QStorageInfo object.

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

Resets QStorageInfo's internal cache.

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

C++ documentation:

Resets QStorageInfo's internal cache.

QStorageInfo caches information about storage to speed up performance. QStorageInfo retrieves information during object construction and/or when calling the setPath() method. You have to manually reset the cache by calling this function to update storage information.

pub unsafe fn root() -> CppBox<QStorageInfo>[src]

Returns a QStorageInfo object that represents the system root volume.

Calls C++ function: static QStorageInfo QStorageInfo::root().

C++ documentation:

Returns a QStorageInfo object that represents the system root volume.

On Unix systems this call returns the root ('/') volume; in Windows the volume where the operating system is installed.

See also isRoot().

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

Returns the mount point of the filesystem this QStorageInfo object represents.

Calls C++ function: QString QStorageInfo::rootPath() const.

C++ documentation:

Returns the mount point of the filesystem this QStorageInfo object represents.

On Windows, it returns the volume letter in case the volume is not mounted to a directory.

Note that the value returned by rootPath() is the real mount point of a volume, and may not be equal to the value passed to the constructor or setPath() method. For example, if you have only the root volume in the system, and pass '/directory' to setPath(), then this method will return '/'.

See also setPath() and device().

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

Sets this QStorageInfo object to the filesystem mounted where path is located.

Calls C++ function: void QStorageInfo::setPath(const QString& path).

C++ documentation:

Sets this QStorageInfo object to the filesystem mounted where path is located.

path can either be a root path of the filesystem, a directory, or a file within that filesystem.

See also rootPath().

pub unsafe fn subvolume(&self) -> CppBox<QByteArray>[src]

Returns the subvolume name for this volume.

Calls C++ function: QByteArray QStorageInfo::subvolume() const.

C++ documentation:

Returns the subvolume name for this volume.

Some filesystem types allow multiple subvolumes inside one device, which may be mounted in different paths. If the subvolume could be detected, it is returned here. The format of the subvolume name is specific to each filesystem type.

If this volume was not mounted from a subvolume of a larger filesystem or if the subvolume could not be detected, this function returns an empty byte array.

This function was introduced in Qt 5.9.

See also device().

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

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

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

C++ documentation:

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

Trait Implementations

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

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

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QStorageInfo& first, const QStorageInfo& second).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

impl CppDeletable for QStorageInfo[src]

unsafe fn delete(&mut self)[src]

Destroys the QStorageInfo object and frees its resources.

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

C++ documentation:

Destroys the QStorageInfo object and frees its resources.

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<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.

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

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

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

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

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