summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-07-27 14:41:19 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-07-30 21:12:21 +0000
commitcc7fcecd7ad3c2d7dcf9d93ba4d7018b9cd111b3 (patch)
treefd0f1c597bc6be8d96cf33540033b41e6f15ebb9
parent62bd4f5852137276e354746737a88c06168c4b8b (diff)
Add QStorageInfo::blockSize
[ChangeLog][QtCore][QStorageInfo] Added QStorageInfo::blockSize(), which returns the optimal block size for data transfer to and from the storage. Change-Id: Ib306f8f647014b399b87ffff13f4eba6000452d4 Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
-rw-r--r--src/corelib/io/qstorageinfo.cpp12
-rw-r--r--src/corelib/io/qstorageinfo.h1
-rw-r--r--src/corelib/io/qstorageinfo_mac.cpp1
-rw-r--r--src/corelib/io/qstorageinfo_p.h3
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp1
5 files changed, 17 insertions, 1 deletions
diff --git a/src/corelib/io/qstorageinfo.cpp b/src/corelib/io/qstorageinfo.cpp
index 337a9c7cef..99a2a1a42a 100644
--- a/src/corelib/io/qstorageinfo.cpp
+++ b/src/corelib/io/qstorageinfo.cpp
@@ -222,6 +222,18 @@ qint64 QStorageInfo::bytesTotal() const
}
/*!
+ \since 5.6
+ 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.
+ */
+int QStorageInfo::blockSize() const
+{
+ return d->blockSize;
+}
+
+/*!
Returns the type name of the filesystem.
This is a platform-dependent function, and filesystem names can vary
diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h
index b9d694cb14..c7a558bb4e 100644
--- a/src/corelib/io/qstorageinfo.h
+++ b/src/corelib/io/qstorageinfo.h
@@ -72,6 +72,7 @@ public:
qint64 bytesTotal() const;
qint64 bytesFree() const;
qint64 bytesAvailable() const;
+ int blockSize() const;
inline bool isRoot() const;
bool isReadOnly() const;
diff --git a/src/corelib/io/qstorageinfo_mac.cpp b/src/corelib/io/qstorageinfo_mac.cpp
index 539af33c5d..1ef9983918 100644
--- a/src/corelib/io/qstorageinfo_mac.cpp
+++ b/src/corelib/io/qstorageinfo_mac.cpp
@@ -76,6 +76,7 @@ void QStorageInfoPrivate::retrievePosixInfo()
device = QByteArray(statfs_buf.f_mntfromname);
readOnly = (statfs_buf.f_flags & MNT_RDONLY) != 0;
fileSystemType = QByteArray(statfs_buf.f_fstypename);
+ blockSize = statfs_buf.f_bsize;
}
}
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 564321bedd..fb3bd8bd5b 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -53,7 +53,7 @@ class QStorageInfoPrivate : public QSharedData
{
public:
inline QStorageInfoPrivate() : QSharedData(),
- bytesTotal(-1), bytesFree(-1), bytesAvailable(-1),
+ bytesTotal(-1), bytesFree(-1), bytesAvailable(-1), blockSize(-1),
readOnly(false), ready(false), valid(false)
{}
@@ -84,6 +84,7 @@ public:
qint64 bytesTotal;
qint64 bytesFree;
qint64 bytesAvailable;
+ int blockSize;
bool readOnly;
bool ready;
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index f82d0ff0a1..83c52dbf2c 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -510,6 +510,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
+ blockSize = statfs_buf.f_bsize;
#if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4)
#if defined(_STATFS_F_FLAGS)
readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;