diff options
Diffstat (limited to 'rbutil/rbutilqt/base/utils.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/utils.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp index 1fdf627378..ca3a6d2256 100644 --- a/rbutil/rbutilqt/base/utils.cpp +++ b/rbutil/rbutilqt/base/utils.cpp | |||
@@ -187,13 +187,25 @@ QString Utils::filesystemName(QString path) | |||
187 | //! @return size in bytes | 187 | //! @return size in bytes |
188 | qulonglong Utils::filesystemFree(QString path) | 188 | qulonglong Utils::filesystemFree(QString path) |
189 | { | 189 | { |
190 | return filesystemSize(path, FilesystemFree); | 190 | qulonglong size = filesystemSize(path, FilesystemFree); |
191 | qDebug() << "[Utils] free disk space for" << path << size; | ||
192 | return size; | ||
191 | } | 193 | } |
192 | 194 | ||
193 | 195 | ||
194 | qulonglong Utils::filesystemTotal(QString path) | 196 | qulonglong Utils::filesystemTotal(QString path) |
195 | { | 197 | { |
196 | return filesystemSize(path, FilesystemTotal); | 198 | qulonglong size = filesystemSize(path, FilesystemTotal); |
199 | qDebug() << "[Utils] total disk space for" << path << size; | ||
200 | return size; | ||
201 | } | ||
202 | |||
203 | |||
204 | qulonglong Utils::filesystemClusterSize(QString path) | ||
205 | { | ||
206 | qulonglong size = filesystemSize(path, FilesystemClusterSize); | ||
207 | qDebug() << "[Utils] cluster size for" << path << size; | ||
208 | return size; | ||
197 | } | 209 | } |
198 | 210 | ||
199 | 211 | ||
@@ -214,6 +226,9 @@ qulonglong Utils::filesystemSize(QString path, enum Utils::Size type) | |||
214 | if(type == FilesystemTotal) { | 226 | if(type == FilesystemTotal) { |
215 | size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_blocks; | 227 | size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_blocks; |
216 | } | 228 | } |
229 | if(type == FilesystemClusterSize) { | ||
230 | size = (qulonglong)fs.f_frsize; | ||
231 | } | ||
217 | } | 232 | } |
218 | #endif | 233 | #endif |
219 | #if defined(Q_OS_WIN32) | 234 | #if defined(Q_OS_WIN32) |
@@ -230,9 +245,19 @@ qulonglong Utils::filesystemSize(QString path, enum Utils::Size type) | |||
230 | if(type == FilesystemTotal) { | 245 | if(type == FilesystemTotal) { |
231 | size = totalNumberBytes.QuadPart; | 246 | size = totalNumberBytes.QuadPart; |
232 | } | 247 | } |
248 | if(type == FilesystemClusterSize) { | ||
249 | DWORD sectorsPerCluster; | ||
250 | DWORD bytesPerSector; | ||
251 | DWORD freeClusters; | ||
252 | DWORD totalClusters; | ||
253 | ret = GetDiskFreeSpaceW((LPCTSTR)path.utf16(), §orsPerCluster, | ||
254 | &bytesPerSector, &freeClusters, &totalClusters); | ||
255 | if(ret) { | ||
256 | size = bytesPerSector * sectorsPerCluster; | ||
257 | } | ||
258 | } | ||
233 | } | 259 | } |
234 | #endif | 260 | #endif |
235 | qDebug() << "[Utils] Filesystem:" << path << size; | ||
236 | return size; | 261 | return size; |
237 | } | 262 | } |
238 | 263 | ||