This fixes a problem that is_symlink(directory_entry) always returns
false, even if directory_entry is indeed a symlink. This change makes
is_symlink(directory_entry) behave the same as is_symlink(path) and
use symlink_status().
When the source path is not absolute and copy_options::create_symlinks is
specified, deduce the relative path from the target location to the source
file to create a symlink. This allows to copy to a path that is not the current
path.
Also, added absolute overloads taking error_code argyment.
Also, when current_path() is used as a default argument to other operations,
and the operation also accepts error_code, use current_path(ec) to report
errors through the error code rather than throwing an exception.
Also, added a test for copy operation.
The updated copy implementation follows C++20 [fs.op.copy] definition
and implements additional copy options.
The new create_directory overloads accepting two paths are functionally
similar to copy_directory, but are compliant with C++20
[fs.op.create.directory]. The copy_directory operation has been deprecated
in favor of create_directory.
The copy_file operation implementation has been inlined into the
detail::copy_file function. The part that copies the file body has been
extracted to a separate function, so that addition of specialized copy
implementations later is possible.
Added copy_options enum, which reflects the enum from C++20. Currently,
only overwrite_existing option is supported. Other options will be added
later.
The old enum copy_option is deprecated in favor of copy_options.
Updated docs to reflect recent changes to copy_file behavior.
This silences compiler warnings about using deprecated language features,
which is out-of-class definition of static constant data members.
Closes https://github.com/boostorg/filesystem/pull/121.
The new option allows to skip dangling directory symlinks when iterating
over a directory using recursive_directory_iterator.
This also updates the operations_test, which failed spuriously because
the test created dangling symlinks for some of its checks. Since the order
of iteration is undefined, the tests sometimes passed, when the dangling
symlinks were encountered late during the iteration.
The directory_options enum reflects the same-named enum from C++20. It is now
supported by both directory_iterator and recursive_directory_iterator. In
particular, both iterators now support skip_permission_denied option.
recursive_directory_iterator is now set to end by default on errors, as
required by C++20. An additional directory_options::pop_on_error policy
is added to allow the iterator recover from an error. When this option is
specified and an error occurs, the iterator repeatedly pops the recursion level
until the pop completes successfully or the end state is reached.
recursive_directory_iterator that have standard counterparts (level,
no_push_pending, no_push_request and no_push) are now deprecated and can be
removed by defining BOOST_FILESYSTEM_NO_DEPRECATED. These members will be
removed in a future release.
Docs and tests updated accordingly. Also, in docs reconstructed release history
for the past releases from Boost release notes.
Fixes https://github.com/boostorg/filesystem/issues/112
Fixes https://github.com/boostorg/filesystem/issues/113
Directory iteration components were moved to separate files to simplify
maintenance of operations.hpp/cpp.
directory_iterator implementation on POSIX platforms has been reworked
to only allocate internal buffer when readdir_r is used. When readdir
is used, the dirent structure returned by readdir is used directly, which
eliminates the potential of buffer overrun in case if some directory name
exceeds the buffer size. This also removes the need to copy dirent members
into the buffer, which improves performance and simplifies maintenance.
For buffer size we now use the max path size as opposed to max filename
size. This is done to minimize the possibility of buffer overruns when
readdir_r is used.
On Windows, use Boost.WinAPI to configure the default target Windows version.
This removes WINVER and _WIN32_WINNT defines in Boost.Filesystem as these
macros should be defined by Boost.WinAPI now.
Additionally, exception.hpp and directory.hpp includes in operations.hpp are
marked as deprecated as operations.hpp do not need those components. Users
are encouraged to include the new headers explicitly in their code, as needed.
This simplifies maintenance of the operations.hpp/cpp files.
Also, moved BOOST_FILESYSTEM_SOURCE definition to the build system files
instead of defining it in every source file.
The rvalue-aware operator/ needs to return an rvalue, not an rvalue reference
so that binding its result to a const reference in the caller's code doesn't
leave a dangling reference. This hampers operator/ efficiency to some degree,
but it is still better than the non-rvalue-aware version as it still allows
to avoid copying the path body.
The non-rvalue-aware operator/ is now creating an automatic variable which will
be returned to leverage NRVO. The previous implementation used to return
an lvalue reference to a temporary, which did not match NRVO criteria[1].
Fixes https://github.com/boostorg/filesystem/issues/110.
Closes https://github.com/boostorg/filesystem/pull/111.
[1]: https://en.cppreference.com/w/cpp/language/copy_elision
std::move is not constexpr in C++11, so we can't use it in a constexpr move
constructor. Also, directory_entry move constructor now uses move constructors
of its data members instead of assignment.
Done some formatting changes to make the code look a bit more unified.
This should silence MSVC warnings about path not being exported when used in
directory_entry. This should also remove unnecessary references to the library
for the inline members of directory_entry.
Removed library exports markup for file_status as there were nothing to export.
Also marked its methods constexpr.
Moved recursive_directory_iterator implementation to the library. MSVC should
not issue warnings since we're only exporting member functions.
Updated BOOST_SCOPED_ENUM emulation use to the more recent macros. Made sure
recursive_directory_iterator implementation uses binary compatible
representation for scoped enums between the library and user's code regardless
of C++ versions used.
Instead of exporting the whole path class, export only the functions that
are actually implemented in the shared library and leave the rest inline.
Also, move the definition of the static constants of the path class to
the header to avoid problems with exporting them from the shared library,
as observed with various MSVC versions and also gcc 7.3 from MinGW-w64.
Also, reduced code duplication and added a more efficient operator/
implementation when rvalue references are available.
When an out-of-memory condition is detected (either by catching std::bad_alloc
or by receiving null on memory allocation), do not propagate the exception and
set an appropriate error code instead. This fix only concerns directory_iterator
and recursive_directory_iterator for now; it is possible that other operations
remain not ready for memory allocation failures.
Also, added recursive_directory_iterator::pop() that returns error code instead
of throwing an exception. This overload is present in C++17.
Fixes https://github.com/boostorg/filesystem/issues/58.
Closes https://github.com/boostorg/filesystem/pull/63.
Switched directory_iterator and recursive_directory_iterator to use
intrusive_ptr internally to reduce the iterator size and avoid virtual
function calls. The iterators now support move semantics. Fixed a warning
about deprecated in C++20 implicit generation of copy constructor and
assignment operator if there is a user-defined destructor.
Also updated a few includes to refer to non-deprecated headers. Trimmed
trailing spaces in headers and sources.
When using Boost.Filesystem from a project compiled as C++/CX code,
compilation fails with a syntax error, because generic is a keyword.
error C2059: syntax error: 'generic'
See section "Generic interfaces" in C++/CX here:
https://msdn.microsoft.com/en-us/library/hh755792.aspx
This reverts commit eaa5f27fc1, reversing
changes made to 23d2fcb9e0.
Although the changes made by the pull request fixed the presenting symptom, the lack of an "always makes progress" invariant is the real problem. The plan is to attack the lack of invariant first, then make further changes are needed.
This resolves a bug where the directory_iterator at the top of the stack
is invalid (ie. an end iterator) if an error occurs. So, you cannot
dereference it, and you cannot use any other method (e.g. no_push) on
it, otherwise std::abort will be called.
Avoid pushing an end iterator onto the directory stack.
[1] https://svn.boost.org/trac/boost/ticket/5403
[2] https://svn.boost.org/trac/boost/ticket/6821#comment:5