141 Commits

Author SHA1 Message Date
Andrey Semashev
cc13e916f9 Added pauses in creation_time_tests to avoid spurious failures on Windows.
Presumably, there's some sort of mismatch between times returned by time()
and file creation timestamps when converted to time_t, which can sometimes
result in a test failure. The pauses ensure there's enough distance
between start, finish and file creation timestamps for the discrepancy
to not matter. Also added debug output.
2020-12-23 10:55:00 +03:00
Andrey Semashev
9cab675b71 Create symlinks in the test directory in the operations tests.
This should resolve spurious test failures due to multiple test instances
interfering with each other by creating and deleting the same symlink.
2020-11-26 01:22:56 +03:00
Andrey Semashev
6c2bf50c3a Fixed space operation on Windows not failing for a non-existing path.
Fixes https://github.com/boostorg/filesystem/issues/167.
2020-11-25 18:15:30 +03:00
Andrey Semashev
a031e4ffa9 Added creation_time operation.
The operation allows to query file creation time.

Implementation partially inspired by:

https://github.com/boostorg/filesystem/pull/134

Closes https://github.com/boostorg/filesystem/pull/134.
2020-08-21 01:32:04 +03:00
Antons Jeļkins
5e54f77425 is_symlink(directory_entry) should use symlink_status().
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().
2020-06-04 21:59:00 +02:00
Andrey Semashev
c653976208 Fixed mklink availability check in operations_test.
Instead of enabling/disabling the test compilation, define a macro when
mklink shell command is detected to be available. Test this macro
in all tests that use this command to create junctions and symlinks
on Windows.

Also, renamed reparce_tag_file_placeholder.cpp test to fix a spelling
error.
2020-05-18 16:03:26 +03:00
Andrey Semashev
559b0c291a In copy, support symlink creation when target directory is not current.
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.
2020-05-11 15:10:23 +03:00
Andrey Semashev
4e6317e4b0 Make copy_file return bool, indicating whether file has been copied.
This corresponds to C++20.
2020-05-09 19:38:50 +03:00
Andrey Semashev
ac02dbed2e Added support for copy_options::update_existing to copy_file. 2020-05-09 19:19:33 +03:00
Andrey Semashev
dea37d899e Added support for copy_options::skip_existing. 2020-05-08 19:09:39 +03:00
Andrey Semashev
f199152b7d Refactored copy_file, added copy_options, deprecated copy_option.
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.
2020-05-05 18:34:20 +03:00
Andrey Semashev
6be120a079 Fixed space test failure for files.
The test used to fail because the path to the file was empty.
2020-05-05 14:35:41 +03:00
Andrey Semashev
a26ead7402 Updated space() behavior to match C++20. Add support for file paths on Windows.
space() now initializes space_info members to -1 values, which is used when the
structure is returned in case of error.

On Windows, check if the path refers to a directory, and use the parent
directory if not. In order to make sure we return space information for the
target filesystem, we have to resolve symlinks in this case.

Fixes https://github.com/boostorg/filesystem/issues/73.
2020-05-05 01:14:00 +03:00
Andrey Semashev
4642ac8e03 Nonessential code formatting cleanup. 2020-05-01 17:22:31 +03:00
Alexander Grund
1dd143e37d
Test for mklink existance before running junction tests 2020-04-25 16:03:52 +02:00
Andrey Semashev
0fcfd93407 Updated lightweight_test.hpp includes to the new location. 2020-03-04 00:49:27 +03:00
Andrey Semashev
03c797998f Added directory_options::skip_dangling_symlinks.
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.
2019-08-20 19:02:56 +03:00
Andrey Semashev
9a14c37d6f Added directory_options. Set recursive_dir_iterator to end or pop on errors.
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
2019-08-02 19:43:46 +03:00
Andrey Semashev
c758552338 Moved directory tools to separate files. Reworked readdir_r support.
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.
2019-08-01 20:34:39 +03:00
Nikita Kniazev
a5c4b21988
operations_test: Enable locale query on MinGW/Cygwin
The `GetUserDefaultUILanguage` is available for a quite long time already (about 19 years for Cygwin, and 7-12 years for MinGW).
2019-04-02 15:29:13 +03:00
Andrey Semashev
5a70ced692 Reverted the previous change regarding warnings aboit slicing exceptions.
Apparently, slicing was intentional, and the test verified that it worked.
This commit restores the previous behavior and disables the gcc warning
instead.
2018-11-24 18:59:08 +03:00
Andrey Semashev
e268f557df Trim trailing spaces in the tests. 2018-11-24 15:23:43 +03:00
Andrey Semashev
d710f5d9d9 Fixed warnings about slicing exceptions and ignoring std::system result. 2018-11-24 15:21:19 +03:00
Peter Dimov
0837d92982 poison_category() was undefined behavior, use a normal one 2018-09-26 01:34:19 +03:00
Peter Dimov
d8a6730d6e Do not return a reference to NULL in poison_category(), to make the test pass on clang with variant=release 2018-01-29 19:29:53 +02:00
Peter Dimov
9a9bf767fb Fix tests to better tolerate parallel execution 2017-12-19 02:44:43 +02:00
Peter Dimov
03eb5df380 Use SetEnvironmentVariableW on Cygwin too 2017-11-22 16:15:26 +02:00
Beman
2550f407f4 MinGW defines __MINGW32__ rather than _MSC_VER, so also test for __MINGW32__ to see if setenv/unsetenv workaround needed. 2016-12-30 10:09:31 -05:00
Beman
163631cc7d ticket #12574 was just user confusion, but are the tests are worth keeping. 2016-11-28 08:29:08 -05:00
Beman
15c7706111 Fix create directory testing boo boo; Turns out " " is a valid file and directory name on Linux (and I'm guessing other POSIX-like systems). Add a POSIX-only test; "/foo" was reported to cause a crash on an earlier version. Don't test this on Windows since a user may well have sufficient permissions to create a directory in root. 2016-11-24 14:34:00 -05:00
Beman Dawes
cbefb2b9f0 Merge pull request #30 from thtrummer/develop
Fix warning, build error, for GCC under Cygwin
2016-11-23 10:46:37 -05:00
Beman
216720de55 Fix #12495, create_directories() crashes when passed empty string as path, from Samantha Ritter. Also affected create_directory(). Charles Olivi submitted a pull request with some particularly helpful test cases. 2016-11-23 09:58:43 -05:00
Beman
5004d7b177 Fix #12578 - Bug in directory_iterator, recursive_directory_iterator, equality testing of copied iterator also at end. 2016-11-23 09:21:32 -05:00
Thomas Trummer
e4d01fc006 Fix build error when using C++11 under Cygwin
http://www.boost.org/development/tests/develop/developer/output/timber-cygwin-boost-bin-v2-libs-filesystem-test-operations_test-test-gcc-5-4-0-debug.html

(Assuming the #ifdef is a copy & paste error)
2016-07-05 11:33:12 +02:00
Beman
2f6391b931 Add class path constexpr constants separator and dot of the type appropriate for the platform, and add class path member query functions filename_is_dot() and filename_is_dot_dot(). These add convenience and the implementations may be more efficient that user coded equivalent functions. Also add detail functions is_directory_separator() and is_element_separator(), and replace all uses of local is_separator() in path.cpp with detail::is_directory_separator(). 2015-12-01 10:17:45 -05:00
Beman
461118d68c Remove debug stmts that should have been removed by prior commit. 2015-09-08 16:21:01 -04:00
Beman
40526c67f2 Clean up some minor cygwin test problems. 2015-09-08 15:40:25 -04:00
Beman
5610f974be Merge branch 'feature/relative2' into develop 2015-09-04 15:24:22 -04:00
Beman
011522bd42 Fix #7258, create_directories returns false if the path ends with a slash. Also fix related issues if path contains dot or dot-dot elements, and add test cases to the test suite. 2015-09-02 08:24:41 -04:00
Beman
c739cee694 Apply normal() to weakly_canonical results, but only when know to be needed or it is not known if it may be needed. 2015-08-19 08:43:36 -04:00
Beman
7d6429554a Bring operational functions weakly_canonical() and relative() up to production quality: move implementations to operations.cpp, add error handling, replace tail recursion with iteration, rename weak_canonical to weakly_canonical. The weak_canonical name grated on me every type I used it. 2015-08-10 07:10:59 -04:00
Beman
8a8c8abecc Rename semi_canonical() to weak_canonical. The STL uses "weak" to denote reduced requirements. 2015-08-08 05:56:55 -04:00
Beman
dc794ea95b Merge branch 'feature/relative' into feature/relative2 2015-08-06 08:08:46 -04:00
Beman
706cf988a9 Revise get_temp_directory() test cases. Drive-by warning removal and partial fix for TortoiseGit-related test harness crashes. 2015-02-03 12:11:44 -05:00
Beman
a89b7af83a Comment out test case until fix is applied. Drive by fix of two curly brace errors that happened to cancel each other out. 2015-01-31 08:56:07 -05:00
Beman
bb5a0ff09d Clear warnings, including new warnings from VC++ 2015 preview. 2015-01-05 10:34:24 -05:00
Beman
9fd93a2008 Fix ticket #7018, operations_test.cpp does not correctly use setenv, including the suggested setenv* void fix. Added comment explaining choice of void fix rather than _putenv fix. 2014-12-30 11:59:53 -05:00
Beman
bf1339e282 Remove use of <boost/test/prg_exec_monitor.hpp>. It has caused trouble for years, and I'm tired of fighting with it. The last straw was adding a Cygwin gcc toolset, only to have <boost/test/prg_exec_monitor.hpp> fail to link. Change to always use <boost/detail/lightweight_main.hpp>, which is trouble-free. 2014-08-06 12:16:06 -04:00
Beman
750a82e20d Revert "Merge branch 'develop' of github.com:boostorg/filesystem into develop"
This reverts commit 4610afc49e9c94bdc084cb13cceeec5912326dc6, reversing
changes made to 6623bde4fe501258a54746273ac337e3d55a6710.
2014-08-05 09:16:57 -04:00
Beman
cc99cc6ceb Merge branch 'develop' into ts-develop 2014-07-31 17:24:34 -04:00