Library Kata "Directory statistics"

Develop a library that can be used to determine the size of directory trees.

The library should run through a directory tree and determine the following for each directory:

  • How many files are contained in the directory and all subdirectories?
  • How many bytes do the files in the directory and all subdirectories contain?
  • How many levels of subdirectories are there in the directory?

Directories at level n therefore cumulate these values for their subdirectories at level n+1.

Contract of the library:

interface IFolderStats {
	void Connect(string rootpath);

	void Start();
	void Stop();

	void Pause();
	void Resume();

	IEnumerable Folders {get;};
	string RootPath {get;};
	Statuses Status {get;};

	event Action Progress;
}

interface IFolder {
	string Path;
	long NumberOfFiles;
	long TotalBytes;
	int Depth;
}

enum Statuses {
	Waiting, // not connected yet
	Connected,
	Running,
	Paused,
	Finished
}

Data collection takes place in the background after calling up Start(). It can be canceled or interrupted and resumed at any time.

Folders provides the current status of the data collection. And Progress is fired for each directory - but contains NumberOfFiles etc. does not contain the data for the directory, but the cumulated values of all previously visited directories.

en_USEnglish