Fix issue #4806: Remove on-disk trees with read-only directories in them.
* subversion/libsvn_subr/io.c (io_set_perms): New; helper function for io_set_*_perms. (io_set_file_perms): Use io_set_perms. (io_set_dir_perms): New; like io_set_file_perms, but for directories. (io_set_readonly_flag): New; helper function for setting the read-only flag. (svn_io_set_file_read_only, svn_io_set_file_read_write): Use io_set_readonly_flag. (svn_io_remove_dir2): On Unix, make the parent directory writable before trying to remove its children. (svn_io_dir_remove_nonrecursive): On Windows, remove a directory's read-only flag before trying to remove the directory.
* subversion/tests/libsvn_subr/io-test.c (create_dir_tree): New helper function. (test_rmtree_all_writable, test_rmtree_file_readonly, test_rmtree_dir_readonly, test_rmtree_all_readonly): New test cases. (test_funcs): Activate the new test cases.
Following up on r1836306, provide an alternative fix for allowing things like "svn commit -F <(echo foo)" that doesn't require a more expensive apr_file_info_get(APR_FINFO_SIZE | APR_FINFO_TYPE) syscall in the low-level and commonly used function.
Instead of additionally blacklisting APR_PIPE handles, rework the code to work under the conditions where `finfo.size` may be wrong. That is, try to read one more byte than necessary, expect to see an EOF, but if we don't (e.g., for pipes), fall through to reading the remaining part of the file chunk-by-chunk.
This approach should work correctly under all possible cases where `finfo. size` is incorrect, and also allows to just ask for APR_FINFO_SIZE, which is generally cheaper. At least on Windows, this uses GetFileSizeEx() and results in a single syscall.
* subversion/libsvn_subr/io.c (stringbuf_from_aprfile): Replace the additional blacklist condition for APR_PIPEs with the approach described above.