Commit Graph

393 Commits

Author SHA1 Message Date
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
Andrey Semashev
700a611850 Corrected console output in copy_test. 2020-07-07 17:28:28 +03:00
Andrey Semashev
a5fd89add9 Added a test for copy(ec) operation. 2020-07-07 15:58:59 +03:00
Andrey Semashev
31aacd5dfd Added CMake self-test jobs to CI. 2020-06-05 15:24:10 +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
16dcdbfa8f Fixed copy_test failures on Windows caused by incorrect symlink target.
The symlink was pointing at a directory rather than a file, which makes a
difference on Windows.
2020-05-12 02:32:36 +03:00
Andrey Semashev
d81944eec4 Added exception handling to copy_test. 2020-05-12 02:08:52 +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
a916a41602
Merge pull request #102 from stima/develop
Correct handling status of reparse point
2020-05-06 14:59:59 +03:00
Roman Savchenko
ed9e019b01 Add test for reparse point that is not symlink 2020-05-06 13:37:28 +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
ee6604657d Fix 99_canonical_with_junction_point test not removing temp directory.
The test used to swich the current directory inside the temp directory
structure, which prevented it from removing it on exit.
2020-05-04 23:04:11 +03:00
Andrey Semashev
89b5152e86 Fixed check for mklink on Windows.
For some unknown reason, Windows 8.1 system shell returns error code 1 when
invoking mklink to test if it exists. To work around this we now analyze
output of the command in the Jamfile. As an added bonus, the test is not
compiled when mklink is not supported.
2020-05-04 20:00:40 +03:00
Alexander Grund
37dd08caa5
Address review comments 2020-05-02 18:39:21 +02:00
Flamefire
ccb22fc517
Add test to trigger bug #99
Resolving junction points in read_symlink and canonical is wrong
2020-05-01 17:02:48 +02: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
b33598605c Updated deprecated uses of boost::bind to silence warnings. 2020-03-04 00:45:48 +03:00
Andrey Semashev
06d8d660a1 Fixed path::lexically_relative to handle empty, dot and dot-dot elements.
The algorithm implementation now ignores empty and dot path elements in the
argument path and accounts dot-dot elements by decreasing the number of
dot-dot elements to generate in the resulting relative path. This is
according to C++17 std::path specification [fs.path.gen]/4.

Fixes https://github.com/boostorg/filesystem/issues/76.
2019-10-05 19:14:21 +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
33806dc726 Removed use of deprecated API. 2019-08-02 21:33:23 +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
27256f9d55 Removed asynch-exceptions=on for MSVC. 2019-01-14 20:46:59 +03:00
Andrey Semashev
c0c93a0c58 Removed linking with Boost.System from docs and examples. 2019-01-14 20:40:06 +03:00
Andrey Semashev
2c1fa1a4a0 Removed linking with Boost.System.
Since Boost.System is now header-only, no need to depend on its library.

Fixes https://github.com/boostorg/filesystem/issues/98.
2019-01-14 20:08:41 +03:00
Andrey Semashev
a5dce21b60 Removed test log. 2018-12-09 01:30:50 +03:00
Andrey Semashev
8de281773f Added definitions for path static constants.
This fixes compilation if user's code attempts to ODR-use the constants.

Fixes https://svn.boost.org/trac10/ticket/12759.
Closes https://github.com/boostorg/filesystem/pull/40.
2018-11-24 20:34:44 +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
3ae9ac8e27 Add global visibility to libboost_filesystem as well 2018-09-26 08:29:28 +03:00
Peter Dimov
7ba4bfb949 Simplify test/Jamfile 2018-09-26 06:05:17 +03:00
Peter Dimov
68909064bd Disable hidden visibility under UBSan for the codecvt-using tests 2018-09-26 05:58:36 +03:00
Peter Dimov
0837d92982 poison_category() was undefined behavior, use a normal one 2018-09-26 01:34:19 +03:00
Peter Dimov
9ed5b9e31d Fix test to better tolerate parallel execution 2018-09-06 07:00:41 +03:00
Peter Dimov
a183553454 Add a test for the fs::copy issue in PR #70/#71 2018-09-05 22:24:09 +03:00
Peter Dimov
f13aa18a93 Fix BOOST_FOREACH support; add test 2018-09-05 07:59:20 +03:00
Beman
cd6fead714 Upgrade MSVC Platform Toolset to 141. 2018-04-10 07:56:37 -04:00
Beman
4bd92f00bb Initial commit of Beman's Windows b2 test script 2018-04-10 07:52:04 -04: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
589bfb0436 Add quick test target (for CI) 2017-12-02 17:59:21 +02:00
Peter Dimov
1290dfa1dc Add #include <boost/next_prior.hpp>; no longer in utility.hpp 2017-12-02 03:59:46 +02:00
Peter Dimov
669d35d8db Merge branch 'feature/fix-op-unit-test' into feature/fix-cygwin-op-test 2017-11-22 17:34:13 +02:00
Peter Dimov
03eb5df380 Use SetEnvironmentVariableW on Cygwin too 2017-11-22 16:15:26 +02:00
Peter Dimov
1dc51988bb Make operations_unit_test take a current directory argument; pass one in test/Jamfile 2017-11-22 05:05:43 +02:00
Beman
07619fb370 Add Beman's local test results to aid tracking changes over time. 2017-08-24 08:00:38 -04:00
Beman
49218481e5 Clean up some tutorial example code and fix the wording for it in the tutorial. Thanks to Anmol-Singh-Jaggi for pull request #11. 2017-08-07 20:01:08 -04:00
Beman
170f483655 Add test/config_info.cpp to increase macro state reporting in hopes of easing debugging on remote machines. 2017-01-08 15:23:42 -05:00
Beman
4ccb6c38f2 Start release history for 1.64 2016-12-30 14:52:52 -05: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
Beman
48faf2b1ee Add deprecated path::generic() 2016-11-22 16:51:45 -05:00
Beman
2f4b634c0c Add some stem() and extension() test cases 2016-11-02 17:03:03 -04: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
Felix Bruns
fcb98ee37e Rename generic() to generic_path(), since generic is a keyword in C++/CX.
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
2016-04-27 14:11:08 +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
3c344a5f0b Revert to lexical functions back to being members of class path. This is not the time to redesign the library's lexical vs operational conventions. It would break existing users mental model of lexical vs operational.
See doc/relative_proposal.html#Add-lexical-functions for additional rationale.
2015-10-25 13:28:49 -04:00
Beman
fb365908ad Clear GCC warnings. 2015-10-08 05:03:51 -04:00
Beman
c026d612f2 String file feature cleanup: Add string_file.hpp to filesystem.hpp. Change string_file.hpp to use boost/filesystem/fstream.hpp for I/O. Add string_file_tests function to operations_unit_test.cpp. 2015-10-07 10:11:18 -04:00
Beman
320423af98 Added size() function to class path. Resolves #6874, Path should have a size() member function. 2015-09-08 16:46:05 -04: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
9d5415d579 Add move constructor, move assignment, where called for in Filesystem TS. 2015-09-06 21:18:01 -04:00
Beman
8ad0258405 Tweak configuration. 2015-09-04 15:28:11 -04:00
Beman
5610f974be Merge branch 'feature/relative2' into develop 2015-09-04 15:24:22 -04:00
Beman
a6900bf517 Update release history and add tests. 2015-09-04 13:41:20 -04:00
Beman
8cd5522161 Initial implementation and docs for path::reverse_iterator. 2015-09-04 11:25:22 -04:00
Beman
e6d10cf716 Fix #10766, parent_path() with redundant separator returns wrong value, by adding examples and notes to the reference documentation to show why the returned value is in fact correct, and to provide rationale for that behavior. See [path.itr], and [path.decompose] parent_path() and filename() sections of the reference docs. 2015-09-03 10:44:20 -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
a2d4f99cc8 Resolve #11166 by mitigating (i.e. reducing the likelihood of) a possible external file system race in remove(), using a slight refinement of the patch supplied by Jeff Epler. Made no attempt to fix or mitigate the thread data race in the test program provided. 2015-09-01 11:34:24 -04:00
Beman
f6aa067256 Minor code and comment tweaks. 2015-08-31 10:23:41 -04:00
Beman
2b019a8483 Fix #11288 A patch to avoid redundant string allocations 2015-08-30 16:44:27 -04:00
Beman
efe50fad52 Work issue, but no fix yet 2015-08-30 16:32:44 -04:00
Beman
23759ba8ec Add lexically_proximate and proximate functions. 2015-08-25 15:05:17 -04:00
Beman
27f8e5fd6a Minor tweaks. 2015-08-25 11:04:21 -04:00
Beman
732609a2da Change member normal() and relative() to non-member lexically_normal() and lexically_relative(). See doc/relative_proposal.html#Add-lexical-functions-as-non-members for rationale. 2015-08-23 09:33:21 -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
b54092e66f Simplify expressions and remove accumulated cruft. 2015-08-13 09:01:59 -04:00
Beman
cb11081a7d Finish initial proposed wording section of relative_proposal.html. Drive-by tweaks to other stuff. Add example/directory_symlink_parent_resolution.cpp, include/boost/filesystem/string_file.hpp, and related infrastructure. 2015-08-12 17:26:03 -04:00
Beman
fe71dc8729 Fix test where Windows and POSIX results differ 2015-08-10 08:34:22 -04:00
Beman
f5da08da74 Initial commit. 2015-08-10 08:15:24 -04:00
Beman
a7ac4c088f Add relative_test to Jamfile, fix Cygwin/GCC C++03 enum constant usage error. 2015-08-10 08:09:48 -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
34dd2c7718 Add a new path member function: "path normal() const;" and change the old deprecated normalize() non-const function to be implemented in terms of the new function. The implementation remains the same, except for returning by value rather than modifying in place. Motivation: Jamie Alsop has identified removal of redundant .. and . elements (i.e. normalization) as a need closely related to the relative path functionality requested by numerous Boost issue requests, the C++ LWG, and NB comments to the Filesystem TS. Given that both lexical and operational relative functionality is needed, there is less risk in providing a well-documented path::normal() lexical function. 2015-08-08 16:29:44 -04:00