diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-07-15 18:13:31 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-07-15 18:13:31 +0000 |
commit | 21a38713a685e04ab1533f487244f2dc2197e01c (patch) | |
tree | aa397ae3fd081edd5225c9142fd35cbed4bb88c3 /rbutil/rbutilqt/base/utils.cpp | |
parent | cad91ed938049037a57e9bcc4c5ad63e45dbc2e6 (diff) | |
download | rockbox-21a38713a685e04ab1533f487244f2dc2197e01c.tar.gz rockbox-21a38713a685e04ab1533f487244f2dc2197e01c.zip |
Show the total size of the volume along with the free space.
This should help identifying the correct player by size, since the free space
is only useful to figure if there is enough space to install Rockbox. Change
units to GiB since that is more useful given the size of current devices.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30139 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/base/utils.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/utils.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp index bd2bce0609..1a8607b8e2 100644 --- a/rbutil/rbutilqt/base/utils.cpp +++ b/rbutil/rbutilqt/base/utils.cpp | |||
@@ -115,6 +115,18 @@ QString Utils::resolvePathCase(QString path) | |||
115 | //! @return size in bytes | 115 | //! @return size in bytes |
116 | qulonglong Utils::filesystemFree(QString path) | 116 | qulonglong Utils::filesystemFree(QString path) |
117 | { | 117 | { |
118 | return filesystemSize(path, FilesystemFree); | ||
119 | } | ||
120 | |||
121 | |||
122 | qulonglong Utils::filesystemTotal(QString path) | ||
123 | { | ||
124 | return filesystemSize(path, FilesystemTotal); | ||
125 | } | ||
126 | |||
127 | |||
128 | qulonglong Utils::filesystemSize(QString path, enum Utils::Size type) | ||
129 | { | ||
118 | qlonglong size = 0; | 130 | qlonglong size = 0; |
119 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) | 131 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) |
120 | // the usage of statfs() is deprecated by the LSB so use statvfs(). | 132 | // the usage of statfs() is deprecated by the LSB so use statvfs(). |
@@ -123,16 +135,30 @@ qulonglong Utils::filesystemFree(QString path) | |||
123 | 135 | ||
124 | ret = statvfs(qPrintable(path), &fs); | 136 | ret = statvfs(qPrintable(path), &fs); |
125 | 137 | ||
126 | if(ret == 0) | 138 | if(ret == 0) { |
127 | size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_bavail; | 139 | if(type == FilesystemFree) { |
140 | size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_bavail; | ||
141 | } | ||
142 | if(type == FilesystemTotal) { | ||
143 | size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_blocks; | ||
144 | } | ||
145 | } | ||
128 | #endif | 146 | #endif |
129 | #if defined(Q_OS_WIN32) | 147 | #if defined(Q_OS_WIN32) |
130 | BOOL ret; | 148 | BOOL ret; |
131 | ULARGE_INTEGER freeAvailBytes; | 149 | ULARGE_INTEGER freeAvailBytes; |
150 | ULARGE_INTEGER totalNumberBytes; | ||
132 | 151 | ||
133 | ret = GetDiskFreeSpaceExW((LPCTSTR)path.utf16(), &freeAvailBytes, NULL, NULL); | 152 | ret = GetDiskFreeSpaceExW((LPCTSTR)path.utf16(), &freeAvailBytes, |
134 | if(ret) | 153 | &totalNumberBytes, NULL); |
135 | size = freeAvailBytes.QuadPart; | 154 | if(ret) { |
155 | if(type == FilesystemFree) { | ||
156 | size = freeAvailBytes.QuadPart; | ||
157 | } | ||
158 | if(type == FilesystemTotal) { | ||
159 | size = totalNumberBytes.QuadPart; | ||
160 | } | ||
161 | } | ||
136 | #endif | 162 | #endif |
137 | qDebug() << "[Utils] Filesystem free:" << path << size; | 163 | qDebug() << "[Utils] Filesystem free:" << path << size; |
138 | return size; | 164 | return size; |