Folder Stats

Library Kata “Folder Stats”

Implement a library to calculate the size of directory trees.

With the lib you can traverse directory trees and determine the following:

  • How many files does the directory and all its sub-dirs contain?
  • What’s the total size in bytes of all files in the directory and its sub-dirs?
  • How many levels of sub-dirs are in the directory tree?

Directories on level n add up those values for their sub-directories on level n+1.

The libraries contract:

Data collection should be done in the background after calling Start(). It can be stopped or paused and resumed at any time.

Folders returns the data collected so far with the most recently finished directory being the last in the collection. Progress will be fired for each directory finished – but note: the data reported is always an accumulation of all directories visited so far.