* 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 status_t
FSRecursiveCalcSize(BInfoWindow *window, CopyLoopControl* loopControl, FSRecursiveCalcSize(BInfoWindow* window, CopyLoopControl* loopControl,
BDirectory *dir, off_t *running_size, int32 *fileCount, int32 *dirCount) BDirectory* dir, off_t* _runningSize, int32* _fileCount, int32* _dirCount)
{ {
dir->Rewind(); dir->Rewind();
BEntry entry; BEntry entry;
@@ -2351,21 +2351,21 @@ FSRecursiveCalcSize(BInfoWindow *window, CopyLoopControl* loopControl,
return kUserCanceled; return kUserCanceled;
StatStruct statbuf; 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)) { if (S_ISDIR(statbuf.st_mode)) {
BDirectory subdir(&entry); BDirectory subdir(&entry);
(*dirCount)++; (*_dirCount)++;
(*running_size) += 1024; status = FSRecursiveCalcSize(window, loopControl, &subdir,
status_t result = FSRecursiveCalcSize(window, loopControl, &subdir, _runningSize, _fileCount, _dirCount);
running_size, fileCount, dirCount); if (status != B_OK)
if (result != B_OK) return status;
return result; } else
} else { (*_fileCount)++;
(*fileCount)++;
(*running_size) += statbuf.st_size + 1024;
// Add to compensate for attributes.
}
} }
return B_OK; return B_OK;
} }