Commit Graph

1414 Commits

Author SHA1 Message Date
Andrey Semashev
54ea0cc2f1 Added macro definitions to disable deprecated CRT warnings on Windows. 2021-10-26 19:03:28 +03:00
Andrey Semashev
c25d453cbd Marked a friend declaration with BOOST_FILESYSTEM_DECL to silence gcc warnings.
Apparently, gcc wants the friend declaration of lex_compare_v3 to be annotated
with BOOST_FILESYSTEM_DECL, same as the previous declaration in the namespace
scope, and emits a -Wattributes warning otherwise.

Closes https://github.com/boostorg/filesystem/issues/213.
2021-10-26 18:25:47 +03:00
Andrey Semashev
88a8677d12 Disable useless MSVC warning about failing to inline __forceinline functions.
Closes https://github.com/boostorg/filesystem/issues/212.
2021-10-26 18:16:03 +03:00
Andrey Semashev
2e5579aec9 Added clang-win jobs to AppVeyor CI. 2021-10-17 22:59:39 +03:00
Andrey Semashev
fc2da43e81 Stop testing exception message contents.
The contents is (a) language dependent and (b) is modified by some
standard libraries (e.g. libstdc++ and Dinkumware) and possibly OS,
which causes test failures on AppVeyor.
2021-10-17 22:54:58 +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
b4c39093cc Reimplemented create_directories for compatibility with v4 paths.
The new implementation is prepared for the removal of the implicit
trailing dots in v4 path. It also no longer uses recursion
internally and therefore is better protected against stack overflows.

As a side effect of this rewrite, create_directories no longer reports
error if the input path consists entirely of dot and dot-dot elements.
This is in line with C++20 std::filesystem behavior.
2021-10-17 21:38:28 +03:00
Andrey Semashev
ec93082b6b Fixed git version check on Mac OS. 2021-09-26 20:38:18 +03:00
Andrey Semashev
3450bd809e Updated link to AppVeyor badge. 2021-09-15 22:11:51 +03:00
Andrey Semashev
eca70cdc75 Added GHA CI timeout. 2021-09-15 21:33:41 +03:00
Andrey Semashev
fa089869f5 Removed installation of unnecessary packages in GHA CI. 2021-09-12 18:26:01 +03:00
Andrey Semashev
a62526ea06 Added a comment why clang 8 uses libstdc++-7 in GHA. 2021-09-12 18:12:22 +03:00
Andrey Semashev
010d20fa39 Updated GitHub Actions CI for better configurability. 2021-09-12 18:06:08 +03:00
Andrey Semashev
c57bdbee1b [ci skip] Nonessential. 2021-09-06 02:22:05 +03:00
Andrey Semashev
a413697830 Specify the number of parallel jobs for CMake. 2021-09-06 02:01:15 +03:00
Andrey Semashev
e221f9a3c5 Nonessential. 2021-09-06 01:10:15 +03:00
Andrey Semashev
fdec6039a1 Moved default shell setting under jobs. 2021-09-06 00:50:41 +03:00
Andrey Semashev
a2cebfc588 Updated links to GitHub Actions CI instead of Travis CI. 2021-09-05 22:46:46 +03:00
Andrey Semashev
60203f8cd2 Removed Travis CI config file. 2021-09-05 22:36:54 +03:00
Andrey Semashev
2123e5cc35 Added GitHub Actions config file. 2021-09-05 22:25:04 +03:00
Andrey Semashev
6c3e0bc75d Disable create_directories test that depends on user permissions.
One of the create_directories tests depends on the function failing
to create directories in the root directory. This normally fails
when the tests run under a normal user, but not when running as
root, which is the case when running GitHub Actions in a container.
2021-09-05 22:25:04 +03:00
Andrey Semashev
34b357acf6 Marked windows_file_codecvt::do_unshift with BOOST_OVERRIDE.
Closes https://github.com/boostorg/filesystem/issues/206.
2021-09-03 13:35:24 +03:00
Andrey Semashev
9794725bda Added a workaround for Linux headers older than 2.6.19.
linux/magic.h was introduced in Linux kernel 2.6.19, building Boost.Filesystem
with older kernel headers would fail because of this. Only include the header
when it is found and fallback to our local constant definitions when it's not.
2021-08-03 14:45:46 +03:00
Andrey Semashev
ce233029bd Corrected backslashes in release notes and reordered them for better locality. 2021-07-30 18:43:21 +03:00
Andrey Semashev
87d3c1fd8a Fix weakly_canonical on Windows if the path contains non-existing elements.
Windows APIs such as GetFileAttributesW perform lexical path normalization
internally, which means e.g. "C:\a\.." resolves to an existing path
even if "C:\a" doesn't. This breaks depection of the longest sequence
of existing path elements in weakly_canonical and results in an error
in canonical that is called on that sequence.

As a workaround, perform forward iteration on Windows, so that we
stop on the first path element that doesn't exist.

Also, while at it, corrected error code reported from weakly_canonical
when status fails with an error.

Closes https://github.com/boostorg/filesystem/issues/201.
2021-07-28 20:05:17 +03:00
Andrey Semashev
d418858839 Convert root dir to preferred separator in path::lexically_normal.
This is consistent with std::filesystem and behavior before
16bd89b7c0.

Closes https://github.com/boostorg/filesystem/issues/200.
2021-07-20 11:42:55 +03:00
Andrey Semashev
9e5a3e231e Added a configure check for init_priority attribute.
Apparently, gcc does not support the attribute on Mac OS 11.4. Since
we can't tell if other systems aren't supported as well, it's better
to check with a configure check. As a side effect, this might add
support for more compilers.

Closes https://github.com/boostorg/filesystem/issues/199.
2021-07-14 18:12:47 +03:00
Andrey Semashev
003f002399 Disable posix_fadvise for Android API < 21.
Closes https://github.com/boostorg/filesystem/issues/198.
2021-07-12 15:50:18 +03:00
Andrey Semashev
97f93a8cdc Added explicit initializer for path locale deleter to work around clang-3.7 bug.
clang-3.7 and possibly other versions require an explicit initializer for
global constant objects, even if they are default-constructible.
2021-07-05 02:09:04 +03:00
Andrey Semashev
007ccb7a5e Init path globals early to allow using Boost.FS during program termination.
This works around recurringissues when Boost.Filesystem is used during
program termination (for example, in Boost.Log, when it performs the final
log file rotation). At that point, the path locale as well as dot and dot-dot
paths may no longer be available.

Also, MSVC 14.2 has a bug[1] that results in a deadlock whet dot or
dot-dot path is being created during program termination, while atexit
callbacks are being run in the main thread. This change works around it
as the new code does not call atexit on initialization of these paths.

This is only supported on MSVC, GCC, Clang and compatible compilers that
support MSVC-specific or GCC-specific means to customize global initialization
order.

[1]: https://github.com/boostorg/log/issues/153
2021-06-28 20:58:35 +03:00
Andrey Semashev
f15a0e9b90 Generate list of Boost library includes for CMake configure checks.
In order to avoid hardcoding library dependencies recursively for the
configure checks performed in CMake build scripts, we generate the list
of all include directories. If there is a unified Boost include tree,
we can use that and avoid filesystem scanning.
2021-06-14 22:47:17 +03:00
Andrey Semashev
2dda038306 Reworked function pointers use and definitions.
Instead of using atomic<> to access global function pointers, use raw
pointers and atomic_ref to access them safely in multi-threaded builds.
This allows to ensure constant initialization of the function pointers,
even in C++03. This also solves the problem of undefined dynamic
initialization order that we previously tried to solve with the
init_priority attribute. The attribute turns out to not work if the
pointers were raw pointers (in single-threaded builds). It is also
not supported by Intel Compiler and possibly other, which required
us to avoid using the function pointer for fill_random.

The resulting code should be simpler and more portable. In order to
check for C++20 std::atomic_ref availability, the older check for <atomic>
header was replaced with a check for std::atomic_ref. If not available,
we're using Boost.Atomic, as before.
2021-06-14 22:09:15 +03:00
Andrey Semashev
08e7a20785 Added runtime detection of getrantom Linux system call.
Fall back to reading /dev/(u)random if getrandom fails with ENOSYS.

Also, extracted the portability macros for atomics to a separate header
to be able to use them in unique_path.cpp. Rearranged function pointers
initialization to decouple the initializer object from the particular
system calls.

For getrandom, the ENOSYS failure is only cached if the compiler supports
specifying global object initialization priority, which is needed to ensure
that the function pointer is initialized before the syscall initializer
in a different TU. If the compiler does not support this feature, just
always attempt getrandom first.
2021-06-14 03:39:03 +03:00
Andrey Semashev
017d8c7d40 Get rid of the separator strings. 2021-06-14 02:32:29 +03:00
Andrey Semashev
2a5ce62a3a Removed unused constants and added a precondition assert. 2021-06-13 21:29:31 +03:00
Andrey Semashev
3e8c8b15f9 Added runtime detection of the statx system call on Linux.
This can be useful if the syscall is present at compile time but fails with
ENOSYS at run time (for example, in Docker containers that restrict the syscall,
even if available on the host).

Additionally, marked statx syscall wrappers with attributes to disable MSAN
for them. It was reported that MSAN on clang 10 is showing errors
accessing uninitialized data in stx_mask, which must be initialized by the
syscall.

Related to https://github.com/boostorg/filesystem/issues/172
Related to https://github.com/boostorg/filesystem/issues/185
2021-06-13 21:10:10 +03:00
Andrey Semashev
ac9d62346f Fixed path_test_v3 on Windows 2021-06-13 13:48:15 +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
96f8ce33d0 Changes docs width and corrected fonts. 2021-06-13 03:45:08 +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
9df2bfab58 Corrected docs formatting and invalid characters.
[ci skip]
2021-06-12 19:54:59 +03:00
Andrey Semashev
45682f8501 Only build windows_file_codecvt on Windows and Cygwin. 2021-06-11 15:11:43 +03:00
Andrey Semashev
f851c4eb41 Moved windows_file_codecvt to library namespace and modernized it.
Closes https://github.com/boostorg/filesystem/issues/195.
2021-06-11 14:48:15 +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
458bb95332 Removed multiline comment to silence gcc warnings. 2021-06-10 01:39:48 +03:00
Andrey Semashev
26a07aad53 Allow creating symlinks on Windows in non-elevated mode.
If Windows is running in Developer mode, it is possible to specify
SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag to CreateSymbolicLinkW
so that the call doesn't require elevated privileges.

While at it, explicitly separated implementation of create_symlink and
create_directory_symlink for POSIX and Windows.
2021-06-09 19:09:24 +03:00
Andrey Semashev
29ef7d683d Reverted using std::filesystem::path to pass paths to file streams.
This doesn't compile with gcc 8 on MinGW-w64, and fails in runtime with
gcc 10.2 and clang 8.0.1 on Cygwin64 because character code conversion errors,
so basically std::filesystem never works with wide paths on Windows.

We still use wide paths as `const wchar_t*` with libc++ though.

Also, changed BOOST_FILESYSTEM_C_STR definition to accept the path as
an argument and use that definition in the tests rather than duplicating it.

Related to https://github.com/boostorg/filesystem/issues/181.
2021-06-09 18:28:28 +03:00