1571 Commits

Author SHA1 Message Date
Andrey Semashev
0f890633c3 v4: Avoid converting slashes in root names in path::lexically_normal.
lexically_normal is supposed to convert directory separators, so it
should not modify the path root name.
2024-01-04 04:07:46 +03:00
Andrey Semashev
18b4e2f94c Rework path::generic_path to remove duplicate separators and retain root name.
std::filesystem::path::generic_string mandates that the returned string
uses *single* forward slashes for directory separators, which means
any duplicates must be removed. Boost.Filesystem now follows this definition,
and also documents that forward slashes are used for directory separators.

Additionally, since only directory separators are supposed to be affected,
in v4 avoid converting any slashes that are part of the path root name. This
is the case on Windows with UNC paths and Windows-specific path prefixes.
Keep v3 behavior unchanged for backward compatibility.

Closes https://github.com/boostorg/filesystem/issues/299.
2024-01-04 04:07:34 +03:00
Andrey Semashev
a5f4935baf Documentation fixes. 2024-01-04 00:27:23 +03:00
Andrey Semashev
15ecb9ea42 Added Windows jobs to GitHub Actions. 2024-01-03 23:21:11 +03:00
Andrey Semashev
d7804075b6 Use unique path for temp file in reparse_tag_file_placeholder test.
This allows the tests to be run in parallel without conflicts.
2024-01-03 23:21:11 +03:00
Andrey Semashev
ae5197fe7d Removed invalid character from docs. 2024-01-03 03:46:54 +03:00
Andrey Semashev
e299a19eb5 Use libstdc++11 with clang prior to 16 in GHA CI.
Clang before version 16 is not compatible with libstdc++13 in C++23 mode.
libstdc++13 is customly installed in GHA ubuntu-22.04 images.
boost-1.84.0
2023-12-05 14:34:31 +03:00
Andrey Semashev
55587bb459 Removed gcc-4.6 job from GHA CI.
gcc-4.6 is no longer supported by Boost.ContainerHash.
2023-12-05 14:30:58 +03:00
Andrey Semashev
eb0d5fd20f Merge pull request #296 from 1178264094/develop
fix the windows function call, the error logic of the return code
2023-12-05 14:13:05 +03:00
zhixingchen
2a0e1eaf5c fix the windows function call, the error logic of the return code 2023-12-05 11:01:47 +08:00
Andrey Semashev
53eabaeabb Added a note about deprecation of Windows versions prior to 10. boost-1.84.0.beta1 2023-10-08 20:51:02 +03:00
Andrey Semashev
be82eff289 Removed string_file.hpp that was deprecated in 1.79.0. 2023-10-04 19:40:55 +03:00
Andrey Semashev
4c621f1577 Removed support for Windows CE that was deprecated in 1.79.0. 2023-10-04 19:40:47 +03:00
Andrey Semashev
78a6c4a6ba Updated cxxstd to 11 in library metadata. 2023-10-01 17:27:38 +03:00
Andrey Semashev
0d58357ab9 Removed noexcept from date/time conversion functions. 2023-09-24 12:07:35 +03:00
Andrey Semashev
f805447b75 Improve robustness of date/time conversions on Windows.
Assume time_t is signed on Windows, which means negative values are
possible and represent dates before January 1, 1970 (which is also
allowed by FILETIME).

In order to increase the effective range of time_t, add/subtract
the offset value in seconds rather than in 100 ns units.

Perform range checks and report error if the input date/time, whether
in time_t or FILETIME, would cause an overflow during conversion.

Fixes https://github.com/boostorg/filesystem/issues/293.
2023-09-24 01:18:36 +03:00
Andrey Semashev
73f2bf064a Renamed check functions to avoid UE macro clash.
Reported in https://github.com/boostorg/filesystem/issues/294.
2023-09-23 00:00:04 +03:00
Andrey Semashev
fe07038a2d Drop C++03 compilers from CI, C++11 is now a requirement.
Due to other Boost libraries that Boost.Filesystem depends on dropping
support for C++03, Boost.Filesystem now requires C++11 as a minimum.
Thus remove C++03 testing from CI and update docs accordingly.
2023-09-08 00:01:50 +03:00
Andrey Semashev
e1345acc70 Avoid infinite loop in copy_file when input file is truncated.
Although concurrent modification of the input file during copy_file is
UB and not a supported use case, still avoid looping indefinitely in this
case. The fix applies to sendfile and copy_file_range implementations
of copy_file.

Related to https://github.com/boostorg/filesystem/issues/292.
2023-09-07 23:26:41 +03:00
Andrey Semashev
16805b5a11 Added missing error code clearing in directory_entry members.
Fixes https://github.com/boostorg/filesystem/issues/291.
2023-08-28 19:47:55 +03:00
Andrey Semashev
e65ddb6ef2 Relax access rights for GetFileTime on Windows.
GetFileTime is documented to require GENERIC_READ access right, but this causes
problems if the file is opened by another process without FILE_SHARE_READ.
In practice, FILE_READ_ATTRIBUTES works, and FILE_READ_EA is also added for
good measure, in case if it matters for SMBv1.

If this doesn't work in some case, we might switch to
GetFileInformationByHandle(Ex) in the future.

Fixes https://github.com/boostorg/filesystem/issues/290.
boost-1.83.0
2023-07-12 19:17:25 +03:00
Andrey Semashev
7bb038fcb8 Added a new cstdio.hpp header with fopen overload.
This overload takes filesystem::path as its first argument to support
wide character paths on Windows. Other than this, the overload is
equivalent to std::fopen.
boost-1.83.0.beta1
2023-06-12 15:02:30 +03:00
Andrey Semashev
ec06980b9a Fixed compilation on Windows. 2023-06-11 23:43:24 +03:00
Andrey Semashev
b794e63216 Marked file status querying functions with error_codes noexcept.
After the recent change to get_reparse_point_tag_ioctl, status functions
should no longer throw if error reporting is done via error_code. This
allows us to mark all file status querying functions with error_code
arguments noexcept, as specified in std::filesystem and Boost.Filesystem
docs.
2023-06-11 21:16:10 +03:00
Andrey Semashev
60839f4911 Fixed incorrect handling of errors in get_reparse_point_tag_ioctl. 2023-06-11 21:13:32 +03:00
Andrey Semashev
b1bf547a55 Added more file type testing functions.
Also, make namespace-scope file testing functions for directory_entry
forward to member functions for better efficiency.
2023-06-11 20:56:20 +03:00
Andrey Semashev
d508d4950f Add dir_entry::refresh and file type observers. Use them in recursive dir_it.
This commit changes behavior of directory_entry constructors and modifiers
that change the stored path in v4: the methods will now automatically query
the filesystem for the file status instead of leaving the cached data
default-initialized. This means that the paths passed to directory_entry
must be valid, otherwise an error will be returned. Filesystem querying
is implemented in the new directory_entry::refresh methods.

The constructors and modifiers that accepted file_status arguments are
now removed in v4. The cached file statuses are an implementation detail,
and eventually we may want to add more cached data, as we add more observers
to directory_entry.

Also added a few file type observers to directory_entry. These observers
allow to avoid querying the filesystem if the full file status is not cached
but the file type is (i.e. when permissions are not cached). This is the case
with readdir-based implementation of directory_iterator, if the underlying
C library supports dirent::d_type field.

recursive_directory_iterator has been updated to use the added file type
observers instead of querying the full status. This may improve performance
of directory iteration.

Closes https://github.com/boostorg/filesystem/issues/288.
2023-06-04 20:18:50 +03:00
Andrey Semashev
1aff314c93 Added clang-16 CI jobs, switch to clang-15 from stock Ubuntu repos. 2023-06-03 21:20:22 +03:00
Andrey Semashev
571d178f4f Use configure-time check to detect dirent::d_type field support.
This potentially allows to support more C libraries that provide file
type information during directory iteration.
2023-06-03 20:15:59 +03:00
Andrey Semashev
5147a88edc Added support for more file types in POSIX directory iterator. 2023-06-03 20:00:38 +03:00
Andrey Semashev
277da85cab Make fstream types move constructible/assignable.
If the standard library fstream types are movable, Boost.Filesystem
counterparts are now movable as well.

Closes https://github.com/boostorg/filesystem/issues/280.
2023-05-22 23:21:56 +03:00
Andrey Semashev
3a596f3533 Renamed BOOST_FILESYSTEM_CXX23_STRING_VIEW_HAS_IMPLICIT_RANGE_CTOR to detail. 2023-05-22 23:00:59 +03:00
Andrey Semashev
a30b36946a Use namespace-scope helper functions in is_convertible_to_path_source. 2023-05-21 17:41:53 +03:00
Andrey Semashev
39b0f3a1fe Check that the type is an iterator in is_path_source_iterator.
This fixes hard compilation error when the passed type is not an iterator
at all. As a result, path constructors from iterators are no longer
selected by the compiler in overload resolution in users' code, when
the caller is passing an initializer list with a pair of non-iterator
elements. Added a test for this fix.

Also, use integral_constant to implement boolean type traits.

Fixes https://github.com/boostorg/filesystem/issues/287.
2023-05-21 17:27:12 +03:00
Andrey Semashev
615881f5ba Added more Windows error codes as indication for unsupported dir info class.
Also extracted the check for the error codes to a separate function for
easier maintenance.

Closes https://github.com/boostorg/filesystem/issues/286.
2023-05-13 16:08:21 +03:00
Andrey Semashev
396eef1398 Restrict generic path comparison operators to avoid ambiguities with std lib.
Path comparison operators that accept arbitrary path source types now require
the other argument to be exactly path. This prevents the compiler from picking
those operators when the other argument is convertible to path. This can happen
even when neither of the arguments are actually paths, e.g. when the
comparison operators are brought into the current scope by a using directive.

Fixes https://github.com/boostorg/filesystem/issues/285.
2023-05-08 00:11:37 +03:00
Andrey Semashev
d53450936d Removed noexcept markup from directory_entry comparisons.
These operators forward to path comparison operators and eventually
path::compare, which are not noexcept and may actually throw.
2023-05-07 20:34:30 +03:00
Andrey Semashev
fcc1bf3eca Added another worksround for SMBv1, this time in directory iterators.
GetFileInformationByHandleEx with information classes that produce FILE_ID_128
fail with a special error code ERROR_INVALID_LEVEL when the filesystem is
SMBv1. Treat this error code the same as ERROR_INVALID_PARAMETER.

Fixes https://github.com/boostorg/filesystem/issues/284.
2023-04-13 19:48:42 +03:00
Andrey Semashev
176fce8e4d Disable -Wl,--no-undefined on OpenBSD.
This flag is broken for shared libraries on OpenBSD as it leaves all libc
symbols unresolved.

Fixes https://github.com/boostorg/filesystem/issues/283.
2023-04-12 00:10:43 +03:00
Andrey Semashev
1db4474d1a Work around incorrect attributes reported on Windows for dirs in SMBv1 shares.
If the file handle for a directory in a SMBv1 share was opened with
FILE_READ_ATTRIBUTES access mode, GetFileInformationByHandleEx with
FileAttributeTagInfo returns FILE_ATTRIBUTE_NORMAL in the attributes, which
affected status, symlink_status and everything depending on those.

Work around this Windows bug by adding FILE_READ_EA everywhere where we need
attributes to be correct.

Also, use GENERIC_READ access mode when we call GetFileTime on the handle
afterwards. GetFileTime documentation explicitly mentions that GENERIC_READ
is required for it.

Fixes https://github.com/boostorg/filesystem/issues/282.
boost-1.82.0
2023-03-31 13:22:03 +03:00
Andrey Semashev
7745d57ca8 Added a note about C++03 deprecation. 2023-03-29 02:08:19 +03:00
Andrey Semashev
656c5922c0 Expanded description of Windows path prefixes. boost-1.82.0.beta1 2023-02-12 02:27:06 +03:00
Andrey Semashev
cace399f2c Added simple_ls to examples Jamfile. 2023-02-12 02:14:26 +03:00
Andrey Semashev
7509619c9e Updated library version selection to avoid ODR violations.
The previous strategy of force-inlining methods that are dependent
on the library version is not effective with MSVC in debug mode,
when linking the static library. The compiler does not inline
methods despite the markup, and during linking the static library
with the user's module the linker may or may not pick up user's
definitions of these methods.

When building the library, do not define path methods that depend
on the library version. Instead, explicitly call v4 internal methods
throughout the implementation. This way the compiled library does not
contain v4 versions of these methods, and therefore does not conflict
with user's definitions of these methods.

Fixes https://github.com/boostorg/filesystem/issues/279.
2023-02-08 01:00:54 +03:00
Andrey Semashev
5bebf7805a Silenced clang warnings about self-assignment. 2023-02-07 14:47:37 +03:00
Andrey Semashev
b3c5e11f16 Silenced clang warnings about unused to_string function. 2023-02-07 13:39:11 +03:00
Andrey Semashev
5f2d434a9d Silenced clang warnings about unnamed types in template parameters. 2023-02-07 13:22:44 +03:00
Andrey Semashev
f6c99195d5 Updated Windows tests for the changed path::remove_filename behavior in v4. 2023-02-07 02:22:48 +03:00
Andrey Semashev
32a3878d6a Updated copyrights. 2023-02-05 20:35:00 +03:00
Andrey Semashev
b6ecf3013d Added v4 path::remove_filename. Added path::replace_filename.
v4 remove_filename works similar to std::filesystem, i.e. preserves
the trailing directory separator after removing the filename.
v3 remove_filename works as before. Its behavior is also useful in
v4, so added a new method remove_filename_and_trailing_separators
with the same behavior.

Also added replace_filename that was previously missing.

remove_filename discrepancy from std::filesystem was reported in:

https://github.com/boostorg/filesystem/issues/271
2023-02-05 20:25:50 +03:00