Chapter 4

Building Directories and Contents

IN THIS CHAPTER

check Creating and deleting directories

check Getting the contents of a directory

check Copying and moving, and why they are related

check Moving and renaming files and why they are similar

Native C++ versions before version 17 provide no functions for creating directories and getting the contents of a directory. (C++ 17 and above provides access to the filesystem library, but it isn’t implemented in most compilers yet.)You need to know two points about this situation:

  • There really is a good reason for this lack. C++ is a general-purpose language. Issues that deal with directories are specific to individual operating systems. Thus it doesn’t make sense to include such features in C++.
  • Some brave rebels have added some functions — and these functions exist in most C++ implementations. These additions are important; otherwise, you’d have to call in to the operating system to create or modify a directory.

C++ has a holdover from the C programming language in the header file stdio.h that includes functions for renaming and removing files and directories. ...

Get C++ All-in-One For Dummies, 4th Edition 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.