[haiku-commits] r42252 - haiku/trunk/src/kits/tracker

Author: axeld
Date: 2011-06-19 20:38:31 +0200 (Sun, 19 Jun 2011)
New Revision: 42252
Changeset: https://dev.haiku-os.org/changeset/42252

Modified:
   haiku/trunk/src/kits/tracker/FSUtils.cpp
Log:
* 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 :-)


Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/FSUtils.cpp    2011-06-19 18:15:25 UTC (rev 
42251)
+++ haiku/trunk/src/kits/tracker/FSUtils.cpp    2011-06-19 18:38:31 UTC (rev 
42252)
@@ -2337,8 +2337,8 @@
 
 
 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 @@
                        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;
 }


Other related posts:

  • » [haiku-commits] r42252 - haiku/trunk/src/kits/tracker - axeld