forked from len0rd/rockbox
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
This commit is contained in:
parent
cad91ed938
commit
21a38713a6
3 changed files with 41 additions and 7 deletions
|
@ -114,6 +114,18 @@ QString Utils::resolvePathCase(QString path)
|
|||
//! @param path path on the filesystem to check
|
||||
//! @return size in bytes
|
||||
qulonglong Utils::filesystemFree(QString path)
|
||||
{
|
||||
return filesystemSize(path, FilesystemFree);
|
||||
}
|
||||
|
||||
|
||||
qulonglong Utils::filesystemTotal(QString path)
|
||||
{
|
||||
return filesystemSize(path, FilesystemTotal);
|
||||
}
|
||||
|
||||
|
||||
qulonglong Utils::filesystemSize(QString path, enum Utils::Size type)
|
||||
{
|
||||
qlonglong size = 0;
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||
|
@ -123,16 +135,30 @@ qulonglong Utils::filesystemFree(QString path)
|
|||
|
||||
ret = statvfs(qPrintable(path), &fs);
|
||||
|
||||
if(ret == 0)
|
||||
size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_bavail;
|
||||
if(ret == 0) {
|
||||
if(type == FilesystemFree) {
|
||||
size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_bavail;
|
||||
}
|
||||
if(type == FilesystemTotal) {
|
||||
size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_blocks;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(Q_OS_WIN32)
|
||||
BOOL ret;
|
||||
ULARGE_INTEGER freeAvailBytes;
|
||||
ULARGE_INTEGER totalNumberBytes;
|
||||
|
||||
ret = GetDiskFreeSpaceExW((LPCTSTR)path.utf16(), &freeAvailBytes, NULL, NULL);
|
||||
if(ret)
|
||||
size = freeAvailBytes.QuadPart;
|
||||
ret = GetDiskFreeSpaceExW((LPCTSTR)path.utf16(), &freeAvailBytes,
|
||||
&totalNumberBytes, NULL);
|
||||
if(ret) {
|
||||
if(type == FilesystemFree) {
|
||||
size = freeAvailBytes.QuadPart;
|
||||
}
|
||||
if(type == FilesystemTotal) {
|
||||
size = totalNumberBytes.QuadPart;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
qDebug() << "[Utils] Filesystem free:" << path << size;
|
||||
return size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue