Commit Graph

74 Commits

Author SHA1 Message Date
Andrey Semashev
b219d9fb8a Added support for string views and boost::container::string.
Path traits and relevant path members were reworked to better support
wider range of types that are compatible with path constructors, assignment
and appending members. Added support for C++17 std::string_view,
boost::string_view and boost::container::string as the possible string
types accepted by path members.

Also extended support for types convertible to one of the string types.
Previously, user's type had to be convertible to a string with a character
type that matches the native path character type. Now all supported character
types are acceptable.

Additionally, restricted members accepting a pair of iterators to only accept
iterators whose value types are one of the supported path character types.

Lastly, path::compare and comparison operators now only accept path arguments,
relying on path conversion constructors to do the job of supporting various
source types. Also removed noexcept from compare as it is using lex_compare
and iterators internally and those can throw.

Closes https://github.com/boostorg/filesystem/issues/208.
2022-08-31 09:52:30 +03:00
Andrey Semashev
bb7dc550d5 Removed mentions of u16string and u32string from docs.
Boost.Filesystem does not support char16_t and char32_t yet, so don't
document related types and APIs in the docs.

Related to https://github.com/boostorg/filesystem/issues/86.
2022-08-14 20:08:10 +03:00
Andrey Semashev
d829a46b31 Deprecated path construction/assignment/appending from container types.
Users are advised to use string types and iterators instead of containers
to construct/assign/append to paths.

In v4, the support for containers is removed.
2022-08-14 19:14:42 +03:00
Andrey Semashev
3ccf3d8afd Return -1 from remove_all() on error.
This matches C++17 behavior.
2021-11-18 14:54:39 +03:00
Andrey Semashev
0307f58a8b Don't append trailing dot in lexically_normal, convert separators in root name.
In v4 path::lexically_normal, don't generate a trailing dot element if the
original path ends with a directory separator or dot. Also omit the trailing
directory separator the normalized path ends with a dot-dot element.

Additionally, convert directory separators to preferred separators in
root name on Windows (in v3 and v4). This may be significant for UNC paths.
2021-11-06 03:57:50 +03:00
Andrey Semashev
0aee13c162 Append a trailing directory separator when appending an empty path in v4.
If the source path ends with a non-empty filename, and the appended path
is empty, C++17 std::filesystem requires to add a trailing directory
separator.
2021-11-06 00:31:19 +03:00
Andrey Semashev
0d413a5e4f Changed v4 path appends for absolute appended paths to match C++17.
Appending an absolute path now results in assigning the path, as
specified in C++17. This change is made for consistency with C++
and other languages that implement path manipulation (e.g. Python).
2021-11-05 23:40:57 +03:00
Andrey Semashev
d13461be0f Implemented root-aware path appending in v4.
In Boost.Filesystem v3 path appending mostly worked as a slight upgrade
of concatenation, where appending would only add directory separators
when necessary, but not consider semantics of the root name and root
directory of the appended paths. This would work well for relative paths,
but produce unexpected results for paths with root names.

In v4, we now implement appending that is aware of root name and directory
of the appendedn paths. This means that appending a path with a root name
and/or directory no longer concatenates the paths, but rather rebases the
appended path on top of the source path. In particular, if the appended path
has a root name different from the source path, the append operation will
act as assignment.

This is closer to C++20 std::filesystem but not exactly the same. The
difference is for the case when the appended path is absolute. The C++20
spec requires assignment in this case, Boost.Filesystem v4 deliberately
omits this check. This is to ensure the correct result for UNC paths on
POSIX systems, where "//net/foo" / "/bar" is expected to produce "//net/bar",
not "/bar".

As part of this work, refactored path constructors and operators for more
optimal implementation and reducing the number of overloads.

Closes https://github.com/boostorg/filesystem/issues/214.
2021-11-05 02:21:55 +03:00
Andrey Semashev
3a323cae2d Removed implicit trailing dot element of the path in v4.
When the path ends with a non-root directory separator, no longer
produce a trailing dot element (filename). Instead, return an empty
path.

This affects not only path iterators and path::filename, but also any
other APIs that rely on them.

Closes https://github.com/boostorg/filesystem/issues/193.
2021-10-17 21:40:19 +03:00
Andrey Semashev
25684a2662 Removed bogus text from docs. 2021-06-13 03:59:52 +03:00
Andrey Semashev
647185388f Corrected docs formatting, consistent spelling of Diermar Kühl's credits. 2021-06-13 03:55:07 +03:00
Andrey Semashev
657d0687e9 Removed "revised" timestamps from the docs, added copyrights.
The "revised" timestamps were outdated and are not updated as the docs
are updated, so better remove them. Update times can be inferred from VCS.
2021-06-13 03:46:46 +03:00
Andrey Semashev
7339882ccf Added BOOST_FILESYSTEM_VERSION 4 and moved breaking path changes to v4.
Boost.Filesystem v4 will contain breaking changes from v3 that are required
for better compatibility with C++17 std::filesystem. It will also remove
the deprecated features of v3.

Updated docs to reflect the differences between v3 and v4. Updated tests
to verify both v3 and v4 where the differences are present.
2021-06-13 03:20:30 +03:00
Andrey Semashev
60e908dfcf Don't return root directory from path::filename().
This is a breaking change.

path::filename accessor now only returns the actual filename or the implied
trailing dot element of the path, if it ends with a separator other than
root directory. This makes boost::filesystem::path behavior closer to that
of std::filesystem::path.

Updated tests and docs accordingly.

Closes https://github.com/boostorg/filesystem/issues/194.
2021-06-10 03:49:30 +03:00
Andrey Semashev
e2371dd89f Updated docs for path::stem and path::extension. 2021-06-10 03:41:37 +03:00
Andrey Semashev
0eb5290401 Added weakly_canonical overloads taking base path as an argument.
This can be useful when current_path is not supported by the system.
2021-05-29 18:40:51 +03:00
Andrey Semashev
3c8408995f Added copy_options::synchronize_data and copy_options::synchronize.
These options allow to synchronize the copied data and attributes with
the permanent storage. Note that by default on POSIX systems copy_file
used to synchronize data in previous releases, and this commit changes
this. The caller now has to explicitly request syncing, as it has
significant performance implications.

Closes https://github.com/boostorg/filesystem/issues/186.
2021-05-17 20:33:57 +03:00
Benjamin Nauck
4e992efc2e
Fix misplaced link opening tag for is_directory
The opening tag was placed between the letter i and s in is_directory
instead of before the i.
2021-03-12 16:57:07 +01: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
7e300b986b Corrected system_complete description in the docs.
The updated description refers to absolute operation instead of
complete, which was deprecated and no longer documented in the
reference section. Also, removed a broken link to non-existing
not in the complete docs.

Closes https://github.com/boostorg/filesystem/pull/154.
2020-07-08 17:54:02 +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
80709a9411 Reworked copy operation. Added create_directory with two paths.
The updated copy implementation follows C++20 [fs.op.copy] definition
and implements additional copy options.

The new create_directory overloads accepting two paths are functionally
similar to copy_directory, but are compliant with C++20
[fs.op.create.directory]. The copy_directory operation has been deprecated
in favor of create_directory.
2020-05-10 03:02:32 +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
8c3ae354a0 Require at most one copy option to be specified in copy_file. 2020-05-08 22:54:19 +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
Glen Fernandes
aaf54ada48 Fix link to use Boost ML archive instead of GMANE 2020-04-09 08:23:40 -04:00
Andrey Semashev
e4de1c4138 Removed "new" content markup, HTML fixes, added lexically_proximate docs. 2019-10-05 23:18:30 +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
Jakub Wilk
97cb638138 Fix typos in documentation. 2016-12-07 12:54:33 +01:00
Beman Dawes
fca046d0c4 Merge pull request #31 from faithandbrave/patch-1
fix docs for signature stem(), extension() member functions
2016-11-26 14:18:26 -05:00
tbeu
ce0be4bfe7 Fix link text 2016-09-13 14:01:19 +02:00
Akira Takahashi
0027b3ef53 fix signature stem(), extension() member functions
`stem()` and `extension()` member functions doesn't have parameter.
2016-07-07 15:55:34 +09: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
5d31852813 Fix typo; thanks to Jonathan Wakely. 2015-09-16 15:32:57 -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
9910eccc13 Documentation for functions lexically_normal, lexically_relative, relative, and weakly_canonical. 2015-09-05 12:02:31 -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
0c68ce8962 Use same style sheet as the rest of the documentation. Tweak tab font size. Fix excessively long lines in tables, synopsis 2015-09-03 09:11:21 -04:00
Beman
95175ef819 Fix #11491, temp_directory_path doesn't return valid temp path on Android. 2015-07-22 11:13:06 -04:00
Beman
9205205043 Cleanup some symbol encoding and presentation issues. 2015-07-22 08:29:45 -04:00
Beman
335a70ca22 Change charset to utf-8 and use © for copyright symbol. 2014-12-29 07:38:57 -05:00
Beman
277180e4f9 Add "Bug Reports" to links bar, and reorder existing links. 2014-12-29 07:32:56 -05:00
Beman Dawes
7f7769d16d Document the reimplementation of path::codecvt() and path::imbue(), adding a section on path usage concerns.
[SVN r83062]
2013-02-21 14:27:10 +00:00
Beman Dawes
60e765873f Doc fixes
[SVN r80613]
2012-09-21 12:57:40 +00:00
Beman Dawes
6f223a28ed Remove spurious path::make_absolute() signature from synopsis - it was removed from class path in 2010 in favor of absolute() non-member operational function.
[SVN r80163]
2012-08-23 21:07:23 +00:00
Beman Dawes
2b74b1a45e Add missing copy_directory semantics. Fixes #5879
[SVN r79946]
2012-08-09 12:59:34 +00:00