gcc/libstdc++-v3
Jonathan Wakely fff148b787 libstdc++: Fix error handling in filesystem::remove_all (PR93201)
When recursing into a directory, any errors that occur while removing a
directory entry are ignored, because the subsequent increment of the
directory iterator clears the error_code object.

This fixes that bug by checking the result of each recursive operation
before incrementing. This is a change in observable behaviour, because
previously other directory entries would still be removed even if one
(or more) couldn't be removed due to errors. Now the operation stops on
the first error, which is what the code intended to do all along. The
standard doesn't specify what happens in this case (because the order
that the entries are processed is unspecified anyway).

It also improves the error reporting so that the name of the file that
could not be removed is included in the filesystem_error exception. This
is done by introducing a new helper type for reporting errors with
additional context and a new function that uses that type. Then the
overload of std::filesystem::remove_all that throws an exception can use
the new function to ensure any exception contains the additional
information.

For std::experimental::filesystem::remove_all just fix the bug where
errors are ignored.

	PR libstdc++/93201
	* src/c++17/fs_ops.cc (do_remove_all): New function implementing more
	detailed error reporting for remove_all. Check result of recursive
	call before incrementing iterator.
	(remove_all(const path&), remove_all(const path&, error_code&)): Use
	do_remove_all.
	* src/filesystem/ops.cc (remove_all(const path&, error_code&)): Check
	result of recursive call before incrementing iterator.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Check errors
	are reported correctly.
	* testsuite/experimental/filesystem/operations/remove_all.cc: Likewise.

From-SVN: r280014
2020-01-08 16:44:45 +00:00
..
config baseline_symbols.txt: Update. 2020-01-01 19:19:51 +00:00
doc Update copyright years. 2020-01-01 12:51:42 +01:00
include Rename condition_variable_any wait* methods to match current draft standard 2020-01-08 03:00:40 +00:00
libsupc++ libstdc++: Define __cpp_lib_three_way_comparison conditionally 2020-01-06 12:06:41 +00:00
po Update copyright years. 2020-01-01 12:51:42 +01:00
python Update copyright years. 2020-01-01 12:51:42 +01:00
scripts Update copyright years. 2020-01-01 12:51:42 +01:00
src libstdc++: Fix error handling in filesystem::remove_all (PR93201) 2020-01-08 16:44:45 +00:00
testsuite libstdc++: Fix error handling in filesystem::remove_all (PR93201) 2020-01-08 16:44:45 +00:00
acinclude.m4
aclocal.m4
ChangeLog libstdc++: Fix error handling in filesystem::remove_all (PR93201) 2020-01-08 16:44:45 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019 Update copyright years. 2020-01-01 12:51:42 +01:00
config.h.in
configure
configure.ac
configure.host
crossconfig.m4
fragment.am
linkage.m4
Makefile.am Update copyright years. 2020-01-01 12:51:42 +01:00
Makefile.in
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.