Commit Graph

1414 Commits

Author SHA1 Message Date
Crypto City
2bd5de6049 disable statx, for static build compatibility 2022-12-31 11:32:20 +00:00
Andrey Semashev
141727b568 Treat dedup files as regular files on Windows.
Deduplicated files are reparse points with IO_REPARSE_TAG_DEDUP tag. Such
files are created by a dedup service running in the background, so a regular
file may be converted to a dedup reparse point at any time and without user's
intervention. For all intents and purposes dedup files should look like
normal, regular files, so it makes sense to report them as such in
Boost.Filesystem methods like status(), symlink_status() and everything
based on those. This commit implements this.

Closes https://github.com/boostorg/filesystem/issues/262.
2022-12-03 02:15:13 +03:00
Andrey Semashev
48933c5573 Handle ERROR_CALL_NOT_IMPLEMENTED in remove_nt6_by_handle.
As with directory iterator, ERROR_CALL_NOT_IMPLEMENTED may be returned
by SetFileInformationByHandle in Wine if it doesn't support a certain
information class. Downgrade to an older info class in this case.
2022-12-03 01:50:37 +03:00
Andrey Semashev
c1a48fcdac Use synchronous IO on file handles created in remove_all NT6 implementation.
This eliminates spinning while iterating over directory contents as by default
file handles created by NtCreateFile are non-blocking. Because of this
NtQueryDirectoryFile didn't block and returned STATUS_PENDING without actually
updating the iteration state. Eventually this would cause directory iteration
to fail with a hard error.
2022-12-03 00:53:11 +03:00
Andrey Semashev
84f70b0a2a Added a new test case for absolute() with UNC path on Windows. 2022-12-03 00:01:40 +03:00
Andrey Semashev
8b71cb11a3 Added more fallbacks to directory_iterator construction.
Added ERROR_CALL_NOT_IMPLEMENTED to the list of error codes that are used
to permanently downgrade directory querying method. This error code is
returned by Wine, which up until version 7.21 did not support
FileIdExtdDirectoryRestartInfo and FileFullDirectoryRestartInfo.

Further, use non-permanent downgrade on ERROR_INVALID_PARAMETER. Apparently,
some mounted filesystems don't implement even the older info classes,
such as FileFullDirectoryRestartInfo and FileIdBothDirectoryRestartInfo.
These info classes are otherwise supported by the system and work on other
filesystems.

Lastly, if querying FileIdBothDirectoryRestartInfo fails, fall back to
NtQueryDirectoryFile API.

Fixes https://github.com/boostorg/filesystem/issues/255.
Fixes https://github.com/boostorg/filesystem/issues/266.
Closes https://github.com/boostorg/filesystem/pull/267.
2022-12-02 16:23:24 +03:00
Andrey Semashev
bd878f47e8 Added missing #endif in path_traits.hpp.
Fixes https://github.com/boostorg/filesystem/issues/268.
2022-12-02 12:12:09 +03:00
Andrey Semashev
98c1dd8946 Updated to GHA checkout@v3 to avoid deprecation warnings. 2022-10-18 14:55:26 +03:00
Andrey Semashev
e3bad3c1c6 Explicitly qualify create_directory call to avoid ambiguity in path ctor.
As the compiler considers filesystem::create_directory overload that takes
path as the second argument, if NULL is defined as nullptr the compiler
attempts to construct path from nullptr, which is ambiguous and causes
compilation error. Remove that overload from the overload set by explicitly
qualifying the call.

Reported in https://github.com/boostorg/filesystem/pull/260.
2022-10-18 13:09:50 +03:00
Andrey Semashev
a85778b325 Updated python package installation in GHA config. 2022-09-09 23:52:13 +03:00
Andrey Semashev
db8e65ca52 Fixed LLVM repository URL in GHA config. 2022-09-09 01:38:54 +03:00
Andrey Semashev
fc3f286506 Added clang 14 and 15 CI jobs. 2022-09-09 01:03:41 +03:00
Andrey Semashev
e2d2472eda std::string_view range constructor will be explicit in libstdc++ 11.4.
As noted here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106808
2022-09-08 23:45:18 +03:00
Andrey Semashev
9613ccfa4a std::string_view range constructor was made explicit in gcc 12.2, not 12.1. 2022-09-02 18:27:29 +03:00
Andrey Semashev
cffb1d1bbd Marked path append operators forceinline. 2022-09-02 02:24:47 +03:00
Andrey Semashev
4069ff5ad0 Added C++23 to gcc-11 CI job, added pre-release gcc-12 job. 2022-09-02 02:20:31 +03:00
Andrey Semashev
b224703125 Added a workaround for gcc 11 compile errors in C++23 mode.
C++23 std::string_view added a range constructor that is constrained with
a concept check that in particular checks if the range is contiguous. In
that check, the range iterator type is checked. Since fs::path members now
test whether the source argument is convertible to std::string_view, that
concept check is performed whenever the overload resolution or SFINAE check
is performed. This caused a problem if the check was performed before
fs::path::iterator is defined, since the result of the check formally
changes when the iterator gets defined.

To work around this, move any fs::path non-template member functions that
call to other members (including constructors) which may involve overload
resolution or SFINAE checks that might require testing whether
std::string_view is constructible from fs::path out of fs::path definition
and past the fs::path::iterator definition.

This was also reported to gcc team:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106808
2022-09-02 02:06:01 +03:00
Andrey Semashev
5d4c1caaab Added basic path compare tests. 2022-08-31 23:15:53 +03:00
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
054b842a58 Added a test for path construction/assignment/appending from a custom string.
This should test path compatibility with user-defined custom string-like types,
including string views.
2022-08-21 19:06:42 +03:00
Andrey Semashev
f540b5a650 Fixed compilation. 2022-08-21 19:01:14 +03:00
Andrey Semashev
349daee54b Moved path_traits.hpp to detail.
The public path_traits.hpp header is deprecated and will be removed. Its
contents are path implementation details and are now in detail.
2022-08-21 18:45:59 +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
2e9e66e843 Marked previously deprecated APIs with attributes to generate warnings.
The warnings can be suppressed by defining BOOST_FILESYSTEM_ALLOW_DEPRECATED
macro when compiling user's code.
2022-08-14 19:52:38 +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
d58eb7a714 Switched gcc-9 to ubuntu-20.04 GHA CI image. 2022-08-14 17:50:38 +03:00
Andrey Semashev
5c8bcc2ba6 Updated copyright years. 2022-08-14 14:02:19 +03:00
Andrey Semashev
7fd03ddcf4 Replaced ubuntu-18.04 GHA CI images with containers.
Also use ubuntu-latest image for jobs that are running in a container.
2022-08-14 13:49:16 +03:00
Andrey Semashev
5864f397cc Fixed a missing include on POSIX systems that don't support *at APIs.
Fixes https://github.com/boostorg/filesystem/issues/250.
2022-08-12 13:01:07 +03:00
Andrey Semashev
476ca7b6c1 Fix weakly_canonical on Windows with long paths prefix.
During its operation, weakly_canonical would call status() on the path
consisting only from the root name of the input path. This would fail
with ERROR_INVALID_FUNCTION if the root name starts with the "\\?\" prefix,
as the root name path is not absolute.

To fix this, we don't check the status of the root name path (which is
not the correct check anyways as it tests the current directory on the
corresponding drive for existence, which is not what we want). Additionally,
avoid calling status() on the paths containing dot and dot-dot elements
during the weakly_canonical execution for the same reason - the "\\?\"
prefix disables most of the path processing in Windows APIs, including
dot and dot-dot elements resolution.

Fixes https://github.com/boostorg/filesystem/issues/247.
2022-08-10 04:57:21 +03:00
Andrey Semashev
1c4e1c01a6 Added a few tests involving Windows long paths. 2022-08-10 01:06:57 +03:00
Andrey Semashev
bf6d461cc7 Use a more appropriate variable name. 2022-08-10 00:36:41 +03:00
Andrey Semashev
bca612381a Moved the last release note to 1.81.0 release.
The relevant fix did not make it to 1.80.0 as it came too late during
the release process.
2022-08-09 20:42:33 +03:00
Olavo Belloc
9c9d127bdd Limit the buffer size for compatibility with previous versions of Windows
The reported error was reproduced on Windows 7 and 8.1, but not on an early
version of Windows 10 (2004).

Closes https://github.com/boostorg/filesystem/pull/246.
Likely fixes https://github.com/boostorg/filesystem/issues/245.
2022-08-08 17:22:18 +03:00
Andrey Semashev
ea22e76552 Updated protection of remove_all against CVE-2022-21658 on Windows.
This follows up the previous update for POSIX.

The new implementation of remove_all on Windows Vista and later uses
NtCreateFile internal function in order to open files relative to
a previously opened directory handle, similar to POSIX openat.
Furthermore, querying file status and removing the file is now also
done through file handles to avoid performing path resolutions.

Closes https://github.com/boostorg/filesystem/issues/224.
2022-07-24 02:52:27 +03:00
Andrey Semashev
36cf9aaf81 Updated protection of remove_all against CVE-2022-21658 on POSIX.
The previous implementation could still allow for following symlinks
while remove_all is running if a directory was replaced with a symlink
higher in the tree than remove_all is currently processing. This was
reported here:

https://github.com/boostorg/filesystem/issues/224#issuecomment-1183738097

The solution is to use POSIX.1-2008 *at APIs to prevent symlink resolution
higher in the directory tree while iterating over the subtree in remove_all.
This required updating the directory iterator construction interface so that
it is possible to pass the base directory fd and return fd of the directory
used by the iterator. This is done via platform-specific params that are
currently defined only for POSIX. Additionally, status, symlink_status and
remove were extended to accept the base directory fd as well.

Other systems, including Windows, remain vulnerable.

Related to https://github.com/boostorg/filesystem/issues/224.
2022-07-17 04:00:07 +03:00
Andrey Semashev
014216f3e5 Replaced literal zeros with NULL in headers.
This is for better code readability and to possibly silence compiler
warnings.
2022-07-17 03:57:48 +03:00
Andrey Semashev
561b964c2e Fixed copy_file sendfile fallback if copy_file_range fails with ENOSYS.
The copy_file_range implementation of copy_file used to set incorrect sendfile
fallback if copy_file_range failed with ENOSYS. The fallback would skip
checking the filesystem type for whether it is supported by sendfile.

Also, wrapped sendfile and copy_file_range implementations in structs to
silence clang warnings about using C++11 feature in C++03 mode: the functions
are in an anonymous namespace and therefore have internal linkage, and
pointers to such functions are not allowed to be used in non-type template
parameters in C++03.
2022-07-17 03:57:04 +03:00
Andrey Semashev
fd3af54208 Disable warnings about unused functions.
Clang triggers -Wunused-function for get_dir_itr_imp_extra_data, which
may or may not be used depending on the target platform. Better to disable
the warning rather than add macro checks.
2022-07-17 03:26:56 +03:00
Andrey Semashev
0601c887b7 Switch to macos-11 GHA image as macos-10.15 is deprecated. 2022-07-17 03:26:39 +03:00
Andrey Semashev
945c2ecf11 Worked around a compilation problem on RTEMS.
Closes https://github.com/boostorg/filesystem/pull/240.
2022-07-07 23:43:07 +03:00
Andrey Semashev
7cd11c770b Moved header that is used in tests to tests. 2022-07-07 23:34:35 +03:00
Andrey Semashev
e9c845db2f Include header.hpp/footer.hpp in .cpp files to silence warnings.
Related to https://github.com/boostorg/filesystem/pull/241.
2022-07-07 23:30:16 +03:00
Andrey Semashev
fcc11010a5 Added VS2022 job and C++20 and C++latest jobs to AppVeyor CI. 2022-06-06 02:52:16 +03:00
Guus Waals
11b28f0ec0 Flip default Emscripten default usage of WASI
When using Emscripten filesystem now links against the POSIX functions
2022-05-15 18:43:42 +03:00
Guus Waals
c33862dd91 Fix logic error in comment 2022-05-15 18:43:42 +03:00
Guus Waals
4d88f86765 Fix standalone wasm define. Rename define.
- Add cmake option to turn WASI API on/off
- Rename BOOST_STANDALONE_WASM => BOOST_FILESYSTEM_STANDALONE_WASM
2022-05-15 18:43:42 +03:00
Guus Waals
ef54f768b8 Implement on top of posix API for emscripten 2022-05-15 18:43:42 +03:00
Andrey Semashev
1f2e37cae5 Added a workaround for GetFileInformationByHandleEx error in dir iterator.
Reproduce the workaround for GetFileInformationByHandleEx returning
ERROR_INVALID_PARAMETER when querying FILE_ATTRIBUTE_TAG_INFO on FAT/exFAT
filesystems in directory iterator construction.

Fixes https://github.com/boostorg/filesystem/issues/237.
2022-05-15 17:20:24 +03:00
Andrey Semashev
15249ba87b Added a workaround for (symlink_)status failing on Windows.
Apparently, GetFileInformationByHandleEx(FileAttributeTagInfo) fails
with ERROR_INVALID_PARAMETER on FAT/exFAT filesystems, which used to
be interpreted as "file not found" result in (symlink_)status(). The
file is clearly present since it was successfully opened before,
and the error is presumably because the filesystem does not support
reparse points and cannot return a ReparseTag.

Check that error code and also ERROR_NOT_SUPPORTED for good measure
and fall back to the legacy code path that works for FAT/exFAT.

Fixes https://github.com/boostorg/filesystem/issues/236.
2022-05-12 16:21:52 +03:00