In the last recipe, we implemented a tool that lists the size of all members of any directory.
In this recipe, we will be counting sizes recursively, too, but this time we will accumulate the size of each file to their filename extension. This way we can print the user a table that lists how many files of each file type we have, and what the average size of such file types is.
In this section, we will implement a little tool that recursively iterates over a given directory. While doing that, it counts the number and size of all files, grouped by their extensions. Finally, it prints which filename extensions exist within that directory, how many there are per extension, and their average file size.
- We need to include necessary headers and we declare that we use namespace
std
andfilesystem
.
#include <iostream> #include <sstream> #include <iomanip> #include <map> #include <filesystem...