Developer Builds Cross-Platform Disk Usage Analyzer in C Using Only Standard Libraries
A developer created a terminal-based disk usage analyzer in C without any external libraries, relying solely on the C standard library and OS system calls. The tool recursively scans directories using nftw(), reports total, used, and available disk space, and displays files sorted by size with ASCII bar charts. Building the project involved fixing three notable bugs, including a faulty realloc call that omitted sizeof, unfiltered directory entries in the file list, and missing cross-platform disk stat support for Windows. Cross-platform compatibility was achieved by splitting disk space queries between statvfs on Linux and macOS and GetDiskFreeSpaceExA on Windows behind a unified function. The single-file project builds on both Linux and Windows via CMake, with the developer noting plans to add depth limits and directory exclusions as future improvements.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in