Chapter 6: Working with Files and Directories in Rust

In the previous chapter, we looked at the details of how Rust uses memory, a key system resource.

In this chapter, we will look at how Rust interacts with another important class of system resources – files and directories. The Rust Standard Library offers a rich set of abstractions that enable platform-independent file and directory operations.

For this chapter, we will review the basics of how files are managed by Unix/Linux, and master the key APIs that the Rust Standard Library provides to deal with files, paths, links, and directories.

Using the Rust Standard Library, we will implement a shell command, rstat, that counts the total number of lines of Rust code in a directory (and its ...

Get Practical System Programming for Rust Developers 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.