|Home Tutorial Reference FAQ Releases Portability V4 V3 Intro V3 Design Deprecated Bug Reports|
Version 4 is a significant revision of the Boost Filesystem library that makes its interface and behavior closer to std::filesystem that was introduced in C++17 and updated in the later standards. It removes the features that were deprecated in Version 3 and makes a number of breaking changes.
Users can select Boost.Filesystem v4 version by defining
BOOST_FILESYSTEM_VERSION macro to 4 when compiling their code. There is no need to separately compile Boost.Filesystem for each library version — a single binary supports both v3 and v4. Users should avoid using both v3 and v4 in the same application as this can lead to subtle bugs.
path::filenameno longer returns root name or root directory if the path contains no other elements. For example, on Windows
path("C:").filename()used to return "C:" and
path("C:\").filename()used to return "\" and both will return an empty path now. This also affects
path::extensionmethods, as those are based on
path::extensionno longer treat a filename that starts with a dot and has no other dots as an extension. Filenames starting with a dot are commonly treated as filenames with an empty extension. The leading dot is used to indicate a hidden file on most UNIX-like systems.
path::iteratorno longer return an implicit trailing dot (".") element if the path ends with a directory separator. Instead, an empty path is returned, similar to C++17 std::filesystem. This also affects other methods that are defined in terms of iterators or filename, such as
lexicographical_compare. For example,
path("a/b/") == path("a/b/.")no longer holds true.
path::lexically_normalno longer produces a trailing dot (".") element and omits a directory separator after a trailing dot-dot ("..") element in the normalized paths.
pathappends consider root name and root directory of the appended path. If the appended path is absolute, or root name is present and differs from the source path, the resulting path is equivalent to the appended path. If root directory is present, the result is the root directory and relative path rebased on top of the root name of the source path. Otherwise, the behavior is similar to v3. This behavior is similar to C++17 std::filesystem.
pathno longer supports construction, assignment or appending from containers of characters. Use string types or iterators as the source for these opereations instead.
path::remove_filenamepreserves the trailing directory separator, so that
falseafter a successful call to
© Copyright Andrey Semashev, 2021-2022
Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt