Patch by Shade: If the volume does not return a valid capacity, don't crash with a division by zero error. Resolves #7103. Thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40236 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2011-01-14 14:06:08 +00:00
parent 51d7642503
commit c5b852f95f
1 changed files with 3 additions and 0 deletions

View File

@ -52,6 +52,9 @@ int32
CalcFreeSpace(BVolume *volume)
{
off_t capacity = volume->Capacity();
if (capacity == 0)
return 100;
int32 percent = static_cast<int32>(volume->FreeBytes() / (capacity / 100));
// warn below 20 MB of free space (if this is less than 10% of free space)