© Moritz Lenz 2020
M. LenzRaku Fundamentals https://doi.org/10.1007/978-1-4842-6109-5_10

10. A File and Directory Usage Graph

Moritz Lenz1 
(1)
Fürth, Bayern, Germany
 

You bought a shiny new 8TB disk just a short while ago, and you’re already getting low disk space warnings. What’s taking up all that space?

To answer this question, and experiment a bit with data visualization, let’s write a small tool that visualizes which files use up how much disk space. We also get to explore some functional programming concepts in the process.

10.1 Reading File Sizes

To visualize file usage, we must first recursively read all directories and files in a given directory and record their sizes. To get a listing of all elements in a directory, we can use the dir1 function, ...

Get Raku Fundamentals: A Primer with Examples, Projects, and Case Studies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.