Chapter 19. Adapting the opendir/readdir API

 

Don’t write 200 lines of code when 10 will do.

 
 --Hal Fulton
 

STL is the meat and grist of your dissertation, stick with it and use it like a heart patient wants to use butter.

 
 --George Frazier

Introduction

In this chapter we’re going to look at the simple UNIX opendir/readdir API and see how, despite having far simpler semantics than the glob API (Chapter 17), the business of writing a serviceable STL extension for it is more involved and results in a collection with more restricted semantics.

The extension described here will be the first involving iterators of class type, something it’s very important to get right. Consequently, I’ll first show you the wrong way to write such classes, and then I’ll ...

Get Extended STL, Volume 1: Collections and Iterators 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.