1538 Commits

Author SHA1 Message Date
Andrey Semashev
715607c274 Added clang-17 GHA jobs. 2024-01-14 22:32:07 +03:00
Andrey Semashev
fba5ef2aa4 Updated copyright year in CI config. 2024-01-14 22:15:48 +03:00
Andrey Semashev
4530e2496c Pass enum values to the compiled library.
Since we now require C++11 scoped enums and removed deprecated enums,
we can now pass copy_options and directory_options to the compiled
library without converting to the underlying type.
2024-01-14 18:28:05 +03:00
Andrey Semashev
5df060e95c Removed deprecated APIs.
Removed APIs that were marked as deprecated a long time ago. Disabled
by default support for path construction, assignment and appending from
container types. Users can still enable this functionality by defining
BOOST_FILESYSTEM_DEPRECATED.

Updated docs, tests and examples accordingly.
2024-01-14 17:48:44 +03:00
Andrey Semashev
c0b3b7f2d8 Use a unique path in cstdio test. 2024-01-14 04:28:35 +03:00
Andrey Semashev
d38f590b52 Use unique filename in narrow character fstream test. 2024-01-14 03:30:28 +03:00
Andrey Semashev
3b55b7b0d3 Use C++11 language features unconditionally.
Use nullptr, rvalue references, default function template parameters,
deleted/defaulted functions, noexcept, final, override and scoped enums.

Don't use constexpr yet, as it would raise MSVC requirement.
2024-01-13 19:32:42 +03:00
Andrey Semashev
fc243122b9 Added a copy_options::ignore_attribute_errors option for copy_file/copy.
The new option allows to ignore errors while copying file attributes
(but not file contents).

Closes https://github.com/boostorg/filesystem/issues/179.
2024-01-13 17:22:16 +03:00
Andrey Semashev
7ff596a8df v4: Make absolute() produce a trailing slash for empty input path.
This follows the absolute() definition in the docs, as in v4 appending
an empty path results in a trailing slash.

Unfortunately, this also influences canonical and weakly_canonical,
so we had to duplicate those for v3 and v4 as well.

Fixes https://github.com/boostorg/filesystem/issues/301.
2024-01-08 20:42:32 +03:00
Andrey Semashev
ccbb58c018 Use unique file name in fstream_test. 2024-01-08 03:33:04 +03:00
Andrey Semashev
d574ae5503 Replaced is_regular with is_regular_file call. 2024-01-08 02:42:23 +03:00
Andrey Semashev
1426ca53b4 v4: Make equivalent() fail if only one of the paths exists.
In v3, equivaluent would successfully return false if one of the paths
existed and the other one didn't. v4 now fails in this case, similar
to std::filesystem.
2024-01-08 02:35:29 +03:00
Andrey Semashev
56c5f6ac1d Updated canonical docs to only require absolute(p, base) to exist.
This reflects the actual implementation and effectively allows
canonical("") to work, which is essential for weakly_canonical("a/b"),
where "a" doesn't exist, to succeed.

Related to https://github.com/boostorg/filesystem/issues/300.
2024-01-07 14:46:17 +03:00
Andrey Semashev
d7e6e3100a Added storage preallocation for the target file in copy_file on Linux.
Use Linux fallocate system call to preallocate storage for the target
file in copy_file backends based on sendfile and copy_file_range. These
backends are only used when the file size is known beforehand, and
preallocating storage allows to reduce filesystem fragmentation and
get an early error if there's not enough free space on the target
filesystem.

Preallocation is only done as an optimization/hint. On filesystems
that do not support it we continue the data copying process as before.
This is why we aren't using posix_fallocate, because glibc contains
an emulation path that is used when the filesystem doesn't support
the functionality. We don't want this emulation, as it would effectively
double the amount of written data.
2024-01-05 15:41:01 +03:00
Andrey Semashev
cf135d3f69 Fix weakly_canonical for relative paths that don't exist in the filesystem.
If the input path is relative and none of its elements exist in the filesystem,
the head path calculated in weakly_canonical is empty. In this case, we still
need to call canonical on it to produce an absolute path (which will be
equivalent to the base path) and append the tail path to it.

Fixes https://github.com/boostorg/filesystem/issues/300.
2024-01-04 19:25:32 +03:00
Andrey Semashev
9361213a91 Added a unique_path overload taking a single error_code& argument.
The overload uses the default path model.

Also, express the default model in native characters to avoid unnecessary
character code conversion.
2024-01-04 18:47:50 +03:00
Andrey Semashev
b87d2790e7 v4: Avoid converting slashes in path root name in path::make_preferred.
Similarly to other methods, make_preferred is only supposed to affect
directory separators and not the slashes that are part of the path
root name.
2024-01-04 04:07:46 +03:00
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