summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src/filesystem/ops.cc
AgeCommit message (Collapse)Author
2018-01-13PR libstdc++/83626 simplify filesystem::remove and filesystem::remove_allredi
Backport from mainline 2018-01-05 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/83626 * src/filesystem/ops.cc (remove(const path&, error_code&)): Remove unnecessary symlink_status call. (remove_all(const path&, error_code&)): Use filesystem::remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256603 138bc75d-0d04-0410-961f-82ee72b054a4
2018-01-05PR libstdc++/83279 handle sendfile not copying entire fileredi
Backport from mainline 2017-12-14 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/83279 * src/filesystem/std-ops.cc (do_copy_file): Handle sendfile not copying entire file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256290 138bc75d-0d04-0410-961f-82ee72b054a4
2018-01-05PR libstdc++/83626 Don't report errors when removing non-existent filesredi
Backport from mainline 2018-01-05 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/83626 * src/filesystem/ops.cc (remove(const path&, error_code&)): Do not report an error for ENOENT. (remove_all(const path&)): Fix type of result variable. (remove_all(const path&, error_code&)): Use non-throwing increment for directory iterator. Call POSIX remove directly to avoid redundant calls to symlink_status. Do not report errors for ENOENT. * testsuite/experimental/filesystem/operations/remove_all.cc: Test throwing overload. Backport from mainline 2018-01-04 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/83626 * src/filesystem/ops.cc (remove(const path&, error_code&))): Remove redundant call to ec.clear(). (remove_all(const path&, error_code&))): Do not return an error for non-existent paths. * testsuite/experimental/filesystem/operations/remove.cc: New test. * testsuite/experimental/filesystem/operations/remove_all.cc: Fix expected results for non-existent paths. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256287 138bc75d-0d04-0410-961f-82ee72b054a4
2018-01-05PR libstdc++/79283 fix filesystem::read_symlink for /procredi
Backport from mainline 2017-10-25 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/79283 * src/filesystem/ops.cc (read_symlink): Handle st_size being zero. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256286 138bc75d-0d04-0410-961f-82ee72b054a4
2017-01-01 Update copyright years.jakub
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243994 138bc75d-0d04-0410-961f-82ee72b054a4
2016-11-12 * src/filesystem/ops.cc (is_empty): Fix typo in exception message.redi
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242341 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-27PR70975 Pass valid offset argument to sendfileuros
PR libstdc++/70975 * src/filesystem/ops.cc (do_copy_file) [_GLIBCXX_USE_SENDFILE]: Pass non-null pointer to sendfile for offset argument. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241629 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-26PR78111 fix fallback code for filesystem::canonicalredi
PR libstdc++/78111 * src/filesystem/ops.cc (canonical): Set error for non-existent path. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241549 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-25Handle negative times in filesystem::last_write_timeredi
* src/filesystem/ops.cc (last_write_time(const path&, file_time_type, error_code&)): Handle negative times correctly. * testsuite/experimental/filesystem/operations/last_write_time.cc: Test writing file times. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241522 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-25Fix error handling in copy_file and equivalentredi
* src/filesystem/ops.cc (do_copy_file): Report an error if source or destination is not a regular file (LWG 2712). (equivalent): Fix error handling and result when only one file exists. * testsuite/experimental/filesystem/operations/copy.cc: Remove files created by tests. Test copying directories. * testsuite/experimental/filesystem/operations/copy_file.cc: Remove files created by tests. * testsuite/experimental/filesystem/operations/equivalent.cc: New. * testsuite/experimental/filesystem/operations/is_empty.cc: New. * testsuite/experimental/filesystem/operations/read_symlink.cc: Remove file created by test. * testsuite/experimental/filesystem/operations/remove_all.cc: New. * testsuite/util/testsuite_fs.h (~scoped_file): Only try to remove file if path is non-empty, to support removal by other means. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241521 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-24Fix error handling in filesystem::is_emptyredi
* src/filesystem/ops.cc (is_empty): Fix error handling. * testsuite/experimental/filesystem/operations/is_empty.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241488 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-24PR71337 fix filesystem::temp_directory_path error handlingredi
PR libstdc++/71337 * src/filesystem/ops.cc (temp_directory_path): Pass error_code argument to other filesystem operations. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Add testcase for inaccessible directory. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241487 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-24Do not retry failed close(3) in filesystem::copyredi
* src/filesystem/ops.cc (close_fd): Remove. (do_copy_file): Just use close(3) instead of close_fd, to prevent retrying on error. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241485 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-24Implement DR resolutions for filesystem::copyredi
* src/filesystem/ops.cc (do_copy_file): Return an error if either source or destination is not a regular file. (copy): Update comment to refer to LWG 2681. Implement 2682 and 2683 resolutions. (read_symlink): Add missing ec.clear(). * testsuite/experimental/filesystem/operations/copy.cc: Update expected behaviour for copying directories with create_symlinks. Verify that error_code arguments are cleared if there's no error. * testsuite/experimental/filesystem/operations/read_symlink.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241484 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-22Ignore perms::symlink_nofollow on non-symlinksredi
* src/filesystem/ops.cc (permissions(const path&, perms, error_code&)): Ignore symlink_nofollow flag if file is not a symlink. * testsuite/experimental/filesystem/operations/permissions.cc: Test symlink_nofollow on non-symlinks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241438 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-21LWG2720 implement filesystem::perms::symlink_nofollowredi
* include/experimental/bits/fs_fwd.h (perms::resolve_symlinks): Replace with symlink_nofollow (LWG 2720). * src/filesystem/ops.cc (permissions(const path&, perms, error_code&)): Handle symlink_nofollow. * testsuite/experimental/filesystem/operations/create_symlink.cc: New test. * testsuite/experimental/filesystem/operations/permissions.cc: Test overload taking error_code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241418 138bc75d-0d04-0410-961f-82ee72b054a4
2016-10-21LWG2725 Fix error reporting for filesystem::existsredi
* include/experimental/bits/fs_ops.h (exists(const path&, error_code&)): Clear error if status is known (LWG 2725). (status(const path&, error_code&)): Handle EOVERFLOW. * testsuite/experimental/filesystem/operations/exists.cc: Test overload taking an error_code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241417 138bc75d-0d04-0410-961f-82ee72b054a4
2016-09-28Check for overflow in filesystem::last_write_timeredi
* include/experimental/bits/fs_fwd.h (file_time_type): Simplify definition. * src/filesystem/ops.cc (file_time): Take error_code parameter and check for overflow. (do_copy_file, last_write_time): Pass error_code in file_time calls. * testsuite/experimental/filesystem/operations/last_write_time.cc: New. * testsuite/util/testsuite_fs.h (scoped_file): Define RAII helper. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240587 138bc75d-0d04-0410-961f-82ee72b054a4
2016-08-15 * src/filesystem/ops.cc: Always include ostream anduros
ext/stdio_filebuf.h. (do_copy_file): Check if _GLIBCXX_USE_FCHMODAT is defined. [_GLIBCXX_USE_SENDFILE]: Fallback to read/write operations in case sendfile fails with ENOSYS or EINVAL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239479 138bc75d-0d04-0410-961f-82ee72b054a4
2016-07-04 PR libstdc++/71313ville
* src/filesystem/ops.cc (remove_all(const path&, error_code&)): Call remove_all for children of a directory. * testsuite/experimental/filesystem/operations/create_directories.cc: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237978 138bc75d-0d04-0410-961f-82ee72b054a4
2016-06-06libstdc++/71320 Add or remove file permissions correctlyredi
PR libstdc++/71320 * src/filesystem/ops.cc (permissions(const path&, perms, error_code&)): Add or remove permissions according to perms argument. * testsuite/experimental/filesystem/operations/permissions.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237136 138bc75d-0d04-0410-961f-82ee72b054a4
2016-05-10libstdc++/71038 fix error checks in filesystem::copy_fileredi
PR libstdc++/71038 * src/filesystem/ops.cc (do_copy_file): Fix backwards conditions. * testsuite/experimental/filesystem/operations/copy_file.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236084 138bc75d-0d04-0410-961f-82ee72b054a4
2016-05-10libstdc++/71036 Handle EEXIST in filesystem::create_directoryredi
PR libstdc++/71036 * src/filesystem/ops.cc (create_dir): Handle EEXIST from mkdir. * testsuite/experimental/filesystem/operations/create_directory.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236076 138bc75d-0d04-0410-961f-82ee72b054a4
2016-05-10libstdc++/71037 Add base path to filesystem::canonical exceptionsredi
PR libstdc++/71037 * src/filesystem/ops.cc (canonical(const path&, const path&)): Add base path to exception. * testsuite/experimental/filesystem/operations/canonical.cc: Test paths contained in exception. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236074 138bc75d-0d04-0410-961f-82ee72b054a4
2016-04-19libstdc++/70609 fix filesystem::copy()redi
PR libstdc++/70609 * src/filesystem/ops.cc (close_fd): New function. (do_copy_file): Set permissions before copying file contents. Check result of closing file descriptors. Don't copy streambuf when file is empty. (copy(const path&, const path&, copy_options, error_code&)): Use lstat for source file when copy_symlinks is set. * testsuite/experimental/filesystem/operations/copy.cc: Test copy(). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235215 138bc75d-0d04-0410-961f-82ee72b054a4
2016-04-19Add noexcept to Filesystem TS operatorsredi
* include/experimental/bits/fs_fwd.h (operator&, operator|, operator^, operator~ operator&=, operator|=, operator^=): Add noexcept to overloaded operators for copy_options, perms and directory_options. * src/filesystem/ops.cc (make_file_type, make_file_status, is_not_found_errno, file_time): Add noexcept. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235214 138bc75d-0d04-0410-961f-82ee72b054a4
2016-01-04 Update copyright years.jakub
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232055 138bc75d-0d04-0410-961f-82ee72b054a4
2015-10-02Enable dual ABI for Filesystem libraryredi
* src/filesystem/Makefile.am: Add cxx11_abi_sources. * src/filesystem/Makefile.in: Regenerate. * src/filesystem/cow-dir.cc: New. * src/filesystem/cow-ops.cc: New. * src/filesystem/cow-path.cc: New. * src/filesystem/dir.cc: Define macro for new ABI. * src/filesystem/ops.cc: Likewise. * src/filesystem/path.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228437 138bc75d-0d04-0410-961f-82ee72b054a4
2015-09-23Limit number of symlinks that canonical() will resolveredi
* src/filesystem/ops.cc (canonical): Simplify error handling and limit number of symlinks that can be resolved. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228043 138bc75d-0d04-0410-961f-82ee72b054a4
2015-09-23Fix filesystem::create_directories() functionredi
* src/filesystem/ops.cc (is_dot, is_dotdot): Define new helpers. (create_directories): Fix error handling. * testsuite/experimental/filesystem/operations/create_directories.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228041 138bc75d-0d04-0410-961f-82ee72b054a4
2015-09-16Implement filesystem::canonical() without realpathredi
PR libstdc++/67173 * acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check _XOPEN_VERSION and PATH_MAX for _GLIBCXX_USE_REALPATH. * config.h.in: Regenerate. * configure: Regenerate. * src/filesystem/ops.cc: (canonical) [!_GLIBCXX_USE_REALPATH]: Add alternative implementation. * testsuite/experimental/filesystem/operations/canonical.cc: New. * testsuite/experimental/filesystem/operations/exists.cc: Add more tests. * testsuite/experimental/filesystem/operations/absolute.cc: Add test variables. * testsuite/experimental/filesystem/operations/copy.cc: Likewise. * testsuite/experimental/filesystem/operations/current_path.cc: Likewise. * testsuite/experimental/filesystem/operations/file_size.cc: Likewise. * testsuite/experimental/filesystem/operations/status.cc: Likewise. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227836 138bc75d-0d04-0410-961f-82ee72b054a4
2015-09-11Fix filesystem::canonical on Solaris 10.redi
PR libstdc++/67173 * src/filesystem/ops.cc (filesystem::canonical): Allocate buffer for realpath on Solaris 10. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227689 138bc75d-0d04-0410-961f-82ee72b054a4
2015-05-15 * src/filesystem/ops.cc (stat_type): Define alias for struct stat andredi
use throughout the file. (make_file_type): New function. (file_size(const path&, error_code&)): Report an error for anything that isn't a regular file. (status(const path&), symlink_status(const path&)): Do not throw for file_type::not_found. (temp_directory_path()): Check additional environment variables. * testsuite/experimental/filesystem/operations/exists.cc: New. * testsuite/experimental/filesystem/operations/file_size.cc: New. * testsuite/experimental/filesystem/operations/status.cc: New. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223224 138bc75d-0d04-0410-961f-82ee72b054a4
2015-05-14 PR libstdc++/66011redi
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for fchmod and sendfile. * config.h.in: Regenerate. * configure: Regenerate. * src/filesystem/ops.cc (do_copy_file): Fix arguments to open(). Do not return after copying contents. Use fchmod, fchmodat, and sendfile when available. (current_path, permissions, space): Use errno not return value. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223196 138bc75d-0d04-0410-961f-82ee72b054a4
2015-05-02 * src/filesystem/ops.cc (last_write_time) [_GLIBCXX_USE_UTIMENSAT]:redi
Set timespec members explicitly instead of with a braced-init-list. [_GLIBCXX_HAVE_UTIME_H]: Use lambda to handle st_atime being a macro. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222718 138bc75d-0d04-0410-961f-82ee72b054a4
2015-05-01 * acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Disable when <dirent.h>redi
is not available. (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for fchmodat. * configure: Regenerate. * config.h.in: Regenerate. * configure.ac: Check for utime.h * include/experimental/fs_path.h (path::string<>) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Remove stray typename keyword. * src/filesystem/dir.cc [!_GLIBCXX_HAVE_DIRENT_H] (DIR, opendir, closedir, dirent, readdir_r): Replace dummy functions with #error. (native_readdir, _Dir::advance): Use readdir when readdir_r is missing. * src/filesystem/ops.cc (do_stat, is_set): Make inline. (last_write_time) [!_GLIBCXX_USE_UTIMENSAT]: Use utime. (permissions) [!_GLIBCXX_USE_FCHMODAT]: Use chmod. (space, temp_directory_path) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Set error_code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222703 138bc75d-0d04-0410-961f-82ee72b054a4
2015-04-30Implement N4100 File System TSredi
* acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Define. (GLIBCXX_CHECK_FILESYSTEM_DEPS): Define. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Enable filesystem TS and check its dependencies. * include/Makefile.am: Add new headers. * include/Makefile.in: Regenerate. * include/bits/locale_conv.h (__do_str_code_cvt, __str_codecvt_in, __str_codecvt_out): Move code conversion logic from wstring_convert into new global functions. (wstring_convert::to_bytes, wstring_convert::from_bytes): Use new functions. (wstring_convert::_M_conv): Remove. * include/bits/quoted_string.h (_Quoted_string): Split out of iomanip. * include/experimental/filesystem: New. * include/experimental/fs_dir.h: New. * include/experimental/fs_fwd.h: New. * include/experimental/fs_ops.h: New. * include/experimental/fs_path.h: New. * include/std/iomanip (_Quoted_string): Move to bits/quoted_string.h. * python/libstdcxx/v6/printers.py (StdExpPathPrinter): Add. * src/Makefile.am (SUBDIRS): Add filesystem. * src/Makefile.in: Regenerate. * src/filesystem/Makefile.am: New. * src/filesystem/Makefile.in: New. * src/filesystem/dir.cc: New. * src/filesystem/ops.cc: New. * src/filesystem/path.cc: New. * testsuite/experimental/filesystem/operations/absolute.cc: New. * testsuite/experimental/filesystem/operations/copy.cc: New. * testsuite/experimental/filesystem/operations/current_path.cc: New. * testsuite/experimental/filesystem/path/append/path.cc: New. * testsuite/experimental/filesystem/path/assign/assign.cc: New. * testsuite/experimental/filesystem/path/assign/copy.cc: New. * testsuite/experimental/filesystem/path/compare/compare.cc: New. * testsuite/experimental/filesystem/path/compare/path.cc: New. * testsuite/experimental/filesystem/path/compare/strings.cc: New. * testsuite/experimental/filesystem/path/concat/path.cc: New. * testsuite/experimental/filesystem/path/concat/strings.cc: New. * testsuite/experimental/filesystem/path/construct/copy.cc: New. * testsuite/experimental/filesystem/path/construct/default.cc: New. * testsuite/experimental/filesystem/path/construct/locale.cc: New. * testsuite/experimental/filesystem/path/construct/range.cc: New. * testsuite/experimental/filesystem/path/decompose/extension.cc: New. * testsuite/experimental/filesystem/path/decompose/filename.cc: New. * testsuite/experimental/filesystem/path/decompose/parent_path.cc: New. * testsuite/experimental/filesystem/path/decompose/relative_path.cc: New. * testsuite/experimental/filesystem/path/decompose/root_directory.cc: New. * testsuite/experimental/filesystem/path/decompose/root_name.cc: New. * testsuite/experimental/filesystem/path/decompose/root_path.cc: New. * testsuite/experimental/filesystem/path/decompose/stem.cc: New. * testsuite/experimental/filesystem/path/generic/generic_string.cc: New. * testsuite/experimental/filesystem/path/itr/traversal.cc: New. * testsuite/experimental/filesystem/path/modifiers/clear.cc: New. * testsuite/experimental/filesystem/path/modifiers/make_preferred.cc: New. * testsuite/experimental/filesystem/path/modifiers/remove_filename.cc: New. * testsuite/experimental/filesystem/path/modifiers/replace_extension.cc: New. * testsuite/experimental/filesystem/path/modifiers/replace_filename.cc: New. * testsuite/experimental/filesystem/path/modifiers/swap.cc: New. * testsuite/experimental/filesystem/path/nonmember/hash_value.cc: New. * testsuite/experimental/filesystem/path/query/empty.cc: New. * testsuite/experimental/filesystem/path/query/has_extension.cc: New. * testsuite/experimental/filesystem/path/query/has_filename.cc: New. * testsuite/experimental/filesystem/path/query/has_parent_path.cc: New. * testsuite/experimental/filesystem/path/query/has_relative_path.cc: New. * testsuite/experimental/filesystem/path/query/has_root_directory.cc: New. * testsuite/experimental/filesystem/path/query/has_root_name.cc: New. * testsuite/experimental/filesystem/path/query/has_root_path.cc: New. * testsuite/experimental/filesystem/path/query/has_stem.cc: New. * testsuite/experimental/filesystem/path/query/is_relative.cc: New. * testsuite/util/testsuite_fs.h: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222654 138bc75d-0d04-0410-961f-82ee72b054a4