1538 Commits

Author SHA1 Message Date
Andrey Semashev
f8024b245c Initialize WinAPI function pointers early, if possible. 2022-01-16 19:19:38 +03:00
Andrey Semashev
e3cebe1e3a Enabled testing with GNU extensions in GitHub Actions. 2022-01-16 18:26:55 +03:00
Andrey Semashev
a1067a33d6 Added clang-13 CI jobs. 2021-12-23 14:24:20 +03:00
Andrey Semashev
7edd9eb612 Use explicit operator+= and operator/= overloads for path and string types.
This is necessary to allow to pass arguments convertible to path and
compatible string types to these operators.

Fixes https://github.com/boostorg/filesystem/issues/223.
2021-12-23 14:06:43 +03:00
Andrey Semashev
fb3992a7df Added path concatenation tests. 2021-12-23 13:38:26 +03:00
Andrey Semashev
04c6e582be Use volatile to make sure globals_retainer is not optimized away.
By using volatile qualifier for the internal member of the globals_retainer
class we ensure the constructor formally has observable behavior, which means
it cannot be optimized away.

Related to https://github.com/boostorg/filesystem/issues/217.
boost-1.78.0
2021-11-23 02:01:37 +03:00
Andrey Semashev
fa53749ac7 Added a workaround for MSVC linker eliminating path globals cleanup.
MSVC and possibly some other compilers that don't support __attribute__((used))
may remove the global p_init_path_globals pointer in a special data section
because it is not referenced anywhere. Add a dummy global object that
references the pointer in its constructor as a workaround.

Fixes https://github.com/boostorg/filesystem/issues/217.
2021-11-22 15:50:05 +03:00
Andrey Semashev
7de22d2dc1 Escape angle brackets in release notes. 2021-11-19 18:07:30 +03:00
Andrey Semashev
0f695acdf9 Replaced magic constant with INVALID_FILE_ATTRIBUTES. 2021-11-18 14:54:39 +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
18a8a3430d Added support for removing read-only files on Windows.
Reworked remove() operation to separate POSIX and Windows implementations.
On Windows, if the file to be removed is read-only, try to reset the read-only
attribute before deleting the file. If deleting fails (other than because the
file is already deleted), try to restore the read-only attribute.

As a side effect, we were able to remove an implementation detail value from
the file_type enum that was used by the old remove() implementation.

Added a test for remove() on a read-only file on Windows. Also added tests
for remove_all(), including for cases with symlinks, hardlinks and read-only
files.

Also, corrected mklink /J argument in tests. The command accepts /j (lowercase)
to the same effect, but the formal help lists /J (uppercase) to create junctions.

Reported in https://github.com/boostorg/filesystem/issues/216.
2021-11-18 14:54:17 +03:00
Andrey Semashev
46c74a2e16 Updated check for apt-add-repository capabilities.
In Ubuntu 20.04 there appeared an updated version of the
software-properties-common package in focal-updates, which ships a newer
apt-add-repository version that doesn't support -P/-S/-U command line arguments.

Since we cannot rely on package version checks to determine apt-add-repository
capabilities, we have to parse its --help output instead.

Also, made source list processing more protected against spaces.
2021-11-16 00:42:18 +03:00
Andrey Semashev
7fc42097cf Make hash_value a template to delay binding with Boost.ContainerHash functions.
This should fix linking errors when the compiler is set to preserve unused
inline functions (-fkeep-inline).

Closes https://github.com/boostorg/filesystem/issues/215.
2021-11-11 18:21:29 +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
37bfbbb376 Updated appending root directory in canonical/weakly_canonical.
Similar to absolute(), canonical/weakly_canonical needed to be updated
to avoid discarding the root name of the path when appending a root
directory during path composition.
2021-11-06 00:23:30 +03:00
Andrey Semashev
cc763cb48e Reworked absolute() to fix appending root directory.
Because of the changed semantics of appending operations in v4, path
composition in absolute() would produce incorrect results because at some
point it would append root directory and therefore discard root name
that was potentially added before. The updated implementation fixes that,
and also fixes the case when the input path is already absolute and
starts with a root directory, and the base path has a root name.
Previously, the returned path would contain the root name from the
base path, while the correct thing to do is to return the input path
as is.
2021-11-05 23:41:31 +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
ecbab750b2 Construct paths in BOOST_TEST_EQ macros from string literals.
This works around lightweight_test bug that it doesn't print C strings
in case of test failures.

Related to https://github.com/boostorg/core/issues/91.
2021-11-05 19:08:38 +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
049e9aad94 Check that linking with bcrypt works in has_bcrypt config test.
This allows to succeed library compilation if BCrypt API is
available in headers but the library is not.
boost-1.78.0.beta1
2021-10-26 20:23:04 +03:00
Andrey Semashev
667f785e93 Disable deprecated CRT warnings on Windows also in tests. 2021-10-26 20:06:48 +03:00
Andrey Semashev
ac821cd53a Marked global constants with unused/used attributes to suppress clang warnings.
The "unused" attribute suppresses warnings emitted by clang for global
constants that are used to hook into early initialization of globals. The
"used" attribute is a precaution to ensure these hooks are not eliminated
by compiler or linker.
2021-10-26 19:49:58 +03:00
Andrey Semashev
df972e9a5d Remove unused constants on Windows to silence clang warnings. 2021-10-26 19:10:01 +03:00
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.
boost-1.77.0
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
16bd89b7c0398d0dc5904148a865ef3fc3ece7ec.

Closes https://github.com/boostorg/filesystem/issues/200.
2021-07-20 11:42:55 +03:00