* Fixed ignoring the result of GetStat() which could cause random values to

be counted (for example already if a directory didn't have its X bit set).
* Instead of doing weird heuristics assuming the size on disk, use the actual
  value the file system reports. This might have side effects on file systems
  that don't report those correctly, which can then be fixed :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42252 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2011-06-19 18:38:31 +00:00
parent ad1263fce3
commit dcb652ca5a
+14 -14
View File
@@ -2337,8 +2337,8 @@ FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix)
status_t
FSRecursiveCalcSize(BInfoWindow *window, CopyLoopControl* loopControl,
BDirectory *dir, off_t *running_size, int32 *fileCount, int32 *dirCount)
FSRecursiveCalcSize(BInfoWindow* window, CopyLoopControl* loopControl,
BDirectory* dir, off_t* _runningSize, int32* _fileCount, int32* _dirCount)
{
dir->Rewind();
BEntry entry;
@@ -2351,21 +2351,21 @@ FSRecursiveCalcSize(BInfoWindow *window, CopyLoopControl* loopControl,
return kUserCanceled;
StatStruct statbuf;
entry.GetStat(&statbuf);
status_t status = entry.GetStat(&statbuf);
if (status != B_OK)
return status;
(*_runningSize) += statbuf.st_blocks * 512;
if (S_ISDIR(statbuf.st_mode)) {
BDirectory subdir(&entry);
(*dirCount)++;
(*running_size) += 1024;
status_t result = FSRecursiveCalcSize(window, loopControl, &subdir,
running_size, fileCount, dirCount);
if (result != B_OK)
return result;
} else {
(*fileCount)++;
(*running_size) += statbuf.st_size + 1024;
// Add to compensate for attributes.
}
(*_dirCount)++;
status = FSRecursiveCalcSize(window, loopControl, &subdir,
_runningSize, _fileCount, _dirCount);
if (status != B_OK)
return status;
} else
(*_fileCount)++;
}
return B_OK;
}