Boost C++ Libraries

Next

Chapter 1. Boost.Filesystem 4

Beman Dawes

Andrey Semashev

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt).

Table of Contents

Introduction
Documentation
Installing and Using the Library
Supported Compilers and Platforms
Building the Library
Configuration Macros
Headers and Namespaces
Tutorial
Introduction
Preliminaries
Reporting the Size of a File
Using Status Queries to Determine File Existence and Type
Directory Iteration and Catching Exceptions
Using Path Decomposition, Plus Sorting Results
Class path: Constructors, Including Unicode
Class path: Generic Format vs. Native Format
Class path: Iterators, Observers, Composition, Decomposition, and Query
Error Reporting
Cautions
Effects and Postconditions not Guaranteed in the Presence of Race Conditions
Exceptions
Portability Guide
Introduction
Name Checking Functions
File and Directory Name Recommendations
Reference
Introduction
Path
Filesystem Operations
Exceptions
I/O Utilities
Frequently Asked Questions
General Questions
Class path Questions
Operational Functions Questions
Boost Filesystem Library Design
Introduction
Requirements
Realities
Rationale
Abandoned Designs
References
Boost Filesystem Version 3
Deprecated Names and Other Features
Breaking Changes
Design
Boost Filesystem Version 4
Breaking Changes
Deprecated Features
Deprecation Rationale
Issue Reporting
Bug Reporting Framework
Using the Framework
Rationale
Changelog
Acknowledgements
Version 1
Version 2
Version 3

The Boost.Filesystem library provides facilities to manipulate files and directories, and the paths that identify them.

The features of the library include:

  • A modern C++ interface, highly compatible with the C++ standard library.

    Many users say the interface is their primary motivation for using Boost.Filesystem. They like its use of familiar idioms based on standard library containers, iterators, and algorithms. They like having errors reported by throwing exceptions.

  • Portability between operating systems.
    • At the C++ syntax level, it is convenient to learn and use one interface regardless of the operating system.
    • At the semantic level, behavior of code is reasonably portable across operating systems.
    • Dual generic or native path format support encourages program portability, yet still allows communication with users in system specific formats.
  • Error handling and reporting via C++ exceptions (the default) or error codes.
    • C++ exceptions are the preferred error reporting mechanism for most applications. The exception thrown includes the detailed error code information important for diagnosing the exact cause of file system errors.
    • Error reporting via error code allows user code that provides detailed error recovery to avoid becoming so littered with try-catch blocks as to be unmaintainable.
  • Suitable for a broad spectrum of applications, ranging from simple script-like operations to extremely complex production code.
    • At the simple script-like end of the spectrum, the intent is not to compete with Python, Perl, or shell languages, but rather to provide filesystem operations when C++ is already the language of choice.
    • Finer grained control over operations and error handling is available to support more complex applications or other cases where throwing exceptions isn't desired.
  • Forms the basis for ISO/IEC TS 18822, the C++ standard library Filesystem Technical Specification.

Next