summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qstorageinfo.cpp6
-rw-r--r--src/corelib/io/qstorageinfo_p.h2
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp18
3 files changed, 16 insertions, 10 deletions
diff --git a/src/corelib/io/qstorageinfo.cpp b/src/corelib/io/qstorageinfo.cpp
index d63b6a2a21..337a9c7cef 100644
--- a/src/corelib/io/qstorageinfo.cpp
+++ b/src/corelib/io/qstorageinfo.cpp
@@ -186,6 +186,8 @@ QString QStorageInfo::rootPath() const
This size can be less than or equal to the free size returned by
bytesFree() function.
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesTotal(), bytesFree()
*/
qint64 QStorageInfo::bytesAvailable() const
@@ -198,6 +200,8 @@ qint64 QStorageInfo::bytesAvailable() const
quotas on the filesystem, this value can be larger than the value
returned by bytesAvailable().
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesTotal(), bytesAvailable()
*/
qint64 QStorageInfo::bytesFree() const
@@ -208,6 +212,8 @@ qint64 QStorageInfo::bytesFree() const
/*!
Returns the total volume size in bytes.
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesFree(), bytesAvailable()
*/
qint64 QStorageInfo::bytesTotal() const
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 9e152df1ad..564321bedd 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(0), bytesFree(0), bytesAvailable(0),
+ bytesTotal(-1), bytesFree(-1), bytesAvailable(-1),
readOnly(false), ready(false), valid(false)
{}
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
index 2190c32c01..a7a0cf4ddb 100644
--- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
+++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
@@ -61,9 +61,9 @@ void tst_QStorageInfo::defaultValues()
QVERIFY(!storage.isRoot());
QVERIFY(storage.device().isEmpty());
QVERIFY(storage.fileSystemType().isEmpty());
- QVERIFY(storage.bytesTotal() == 0);
- QVERIFY(storage.bytesFree() == 0);
- QVERIFY(storage.bytesAvailable() == 0);
+ QVERIFY(storage.bytesTotal() == -1);
+ QVERIFY(storage.bytesFree() == -1);
+ QVERIFY(storage.bytesAvailable() == -1);
}
void tst_QStorageInfo::operatorEqual()
@@ -106,9 +106,9 @@ void tst_QStorageInfo::root()
QVERIFY(!storage.device().isEmpty());
QVERIFY(!storage.fileSystemType().isEmpty());
#ifndef Q_OS_HAIKU
- QVERIFY(storage.bytesTotal() > 0);
- QVERIFY(storage.bytesFree() > 0);
- QVERIFY(storage.bytesAvailable() > 0);
+ QVERIFY(storage.bytesTotal() >= 0);
+ QVERIFY(storage.bytesFree() >= 0);
+ QVERIFY(storage.bytesAvailable() >= 0);
#endif
}
@@ -121,9 +121,9 @@ void tst_QStorageInfo::currentStorage()
QVERIFY(appPath.startsWith(storage.rootPath(), Qt::CaseInsensitive));
QVERIFY(!storage.device().isEmpty());
QVERIFY(!storage.fileSystemType().isEmpty());
- QVERIFY(storage.bytesTotal() > 0);
- QVERIFY(storage.bytesFree() > 0);
- QVERIFY(storage.bytesAvailable() > 0);
+ QVERIFY(storage.bytesTotal() >= 0);
+ QVERIFY(storage.bytesFree() >= 0);
+ QVERIFY(storage.bytesAvailable() >= 0);
}
void tst_QStorageInfo::storageList()