Commit Graph

1414 Commits

Author SHA1 Message Date
Andrey Semashev
87181d517d Removed MSVC projects as they are not maintained. 2021-05-19 03:19:08 +03:00
Andrey Semashev
dc65ed5213 Added definitions of filesystem type magic constants. 2021-05-19 03:19:08 +03:00
Andrey Semashev
129d847f8f Added a link to LKML discussion re copy_file_range and procfs/sysfs/etc. 2021-05-19 02:37:28 +03:00
Andrey Semashev
88c2a2df8c Check the source filesystem type before using sendfile/copy_file_range.
Some filesystems have regular files with generated content. Such files have
arbitrary size, including zero, but have actual content. Linux system calls
sendfile or copy_file_range will not copy contents of such files, so we must
use a read/write loop to handle them.

Check the type of the source filesystem before using sendfile or
copy_file_range and fallback to the read/write loop if it matches one of
the blacklisted filesystems: procfs, sysfs, tracefs or debugfs.

Also, added a test to verify that copy_file works on procfs.
2021-05-19 01:43:22 +03:00
Andrey Semashev
9a35774ede Call posix_fadvise to indicate that source file will be read sequentially. 2021-05-19 00:48:03 +03:00
Andrey Semashev
b27ad65326 Increased the minimum buffer size in read/write loop in copy_file.
Also, take into account the target filesystem block size, if available.
2021-05-19 00:22:31 +03:00
Andrey Semashev
4b9052f1e0 Fallback to read/write loop if sendfile/copy_file_range fail.
Since sendfile and copy_file_range can fail for some filesystems
(e.g. eCryptFS), we have to fallback to the read/write loop in copy_file
implementation. Additionally, since we implement the fallback now,
fallback to sendfile if copy_file_range fails with EXDEV and use
copy_file_range on older kernels that don't implement it for
cross-filesystem copying. This may be beneficial if copy_file_range
is used within a filesystem, and is performed on a remote server NFS or CIFS).

Also, it was discovered that copy_file_range can also fail with EOPNOTSUPP
when it is performed on an NFSv4 filesystem and the remote server does
not support COPY operation. This happens on some patched kernels in RHEL/CentOS.

Lastly, to make sure the copy_file_data pointer is accessed atomically,
it is now declared as an atomic value. If std::atomic is unavailable,
Boost.Atomic is used.

Fixes https://github.com/boostorg/filesystem/issues/184.
2021-05-18 23:16:02 +03:00
Andrey Semashev
e320bfaa01 Added tests for copy_options::synchronize(_data). 2021-05-17 21:52:46 +03:00
Andrey Semashev
59e3644803 Added definition of COPY_FILE_NO_BUFFERING for Cygwin, MinGW and MinGW-w64. 2021-05-17 21:35:48 +03:00
Andrey Semashev
f5ebcfcd49 Don't indicate error in copy_file if close fails with EINTR. 2021-05-17 21:26:37 +03:00
Andrey Semashev
3c8408995f Added copy_options::synchronize_data and copy_options::synchronize.
These options allow to synchronize the copied data and attributes with
the permanent storage. Note that by default on POSIX systems copy_file
used to synchronize data in previous releases, and this commit changes
this. The caller now has to explicitly request syncing, as it has
significant performance implications.

Closes https://github.com/boostorg/filesystem/issues/186.
2021-05-17 20:33:57 +03:00
Andrey Semashev
be900df3e6 Added EINTR handling on close(2).
At least HP-UX is known to leave the file descriptor open if close() returns
EINTR. On other systems (Linux, BSD, Solaris, AIX) the file descriptor
is closed in the same situation, and closing it again may potentially close
the wrong descriptor if it is reused by another thread. We introduce
close_fd internal helper to abstract away these platform differences.
2021-05-17 18:39:46 +03:00
Andrey Semashev
8c676eaf8f Avoid comparing pointers to a literal zero. 2021-05-17 17:40:20 +03:00
Andrey Semashev
92262db736 Added EINTR handling for fsync/fdatasync. 2021-05-17 17:22:00 +03:00
Andrey Semashev
9dadc8c90f Minor code cleanup. 2021-05-16 23:41:31 +03:00
Andrey Semashev
c6ac51fb82 Added file creation time checks to CMakeLists.txt. 2021-05-16 23:14:09 +03:00
Andrey Semashev
857c33deda Switched clang CI jobs to Bionic since there are installation errors on Focal. 2021-05-16 23:10:04 +03:00
Andrey Semashev
16dea0f36e Added gcc-11 to Travis CI. 2021-05-16 23:06:31 +03:00
Andrey Semashev
8e03e44920 Cleanup portability functions. 2021-05-16 22:57:16 +03:00
Andrey Semashev
0ecacd5da7 Updated CMakeLists.txt to reflect latest changes. 2021-05-16 22:46:11 +03:00
Andrey Semashev
05de74a000 Added config macros for disabling use of some system APIs.
By defining these new config macros the user can configure the library
to avoid using some system APIs even if they are detected as available
by the library build scripts. This can be useful in case if the API
is known to consistently fail at runtime on the target system.

Related to https://github.com/boostorg/filesystem/issues/172.
2021-05-16 20:44:09 +03:00
Andrey Semashev
4319cf1388 Another attempt to workaround clang < 3.9 bug. 2021-04-25 02:48:56 +03:00
Andrey Semashev
1b27455cb2 Removed unused variables in path_unit_test. 2021-04-24 23:59:24 +03:00
Andrey Semashev
d8dd339d91 Added a workaround for clang 3.5-3.8 compiler error due to no user-defined default ctor in error category. 2021-04-24 23:56:27 +03:00
Andrey Semashev
ef582a0df5 Added clang 11 and 12 jobs to Travis CI. 2021-04-24 22:43:58 +03:00
Andrey Semashev
c03249c375 Reformatted code for more consistent look and better readability. 2021-04-24 22:37:57 +03:00
Andrey Semashev
83429c9bfd Check file status for status_error in create_directories.
create_directories used to ignore errors returned by status()
calls issued internally. The operation would likely fail anyway,
but the error codes returned by create_directories would be incorrect.
Also, it is better to terminate the operation as early as possible
when an error is encountered.

Reported in https://github.com/boostorg/filesystem/issues/182.
2021-03-29 20:20:34 +03:00
Andrey Semashev
62515b937c
Merge pull request #177 from hyarion/develop
Fix misplaced link opening tag for is_directory
2021-03-12 21:59:22 +03:00
Benjamin Nauck
4e992efc2e
Fix misplaced link opening tag for is_directory
The opening tag was placed between the letter i and s in is_directory
instead of before the i.
2021-03-12 16:57:07 +01:00
Andrey Semashev
cc57d28995 Fixed an exception being thrown by path::remove_filename if the path is "////".
Also added tests verifying the case.

Fixes https://github.com/boostorg/filesystem/issues/176.
2021-02-26 14:51:04 +03:00
Andrey Semashev
4137a9d6b1 Marked filesystem_error with VISIBLE and exported members with DECL macros.
This makes a difference in case if Boost.Filesystem is linked statically into
user's application. In this case filesystem_error used to be not marked as
publicly visible, which could make it impossible to catch the exception if
it crossed shared library boundary. By marking the class as publicly visible
we ensure that RTTI is always visible, even in static builds.

The exported members are also marked with dllexport/dllimport attributes
for compatibility with Windows.
2021-02-02 20:34:02 +03:00
Glen Fernandes
cb1dddaec0 Update maintainer list 2021-01-26 15:57:18 -05:00
Andrey Semashev
c3ab391c8d
[skip ci] Merge pull request #175 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 11:16:50 +03:00
Edward Diener
d460125210 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 17:02:00 -05:00
Andrey Semashev
d3d8d12afa Added a release note about updated WASI support. 2020-12-23 11:15:04 +03:00
Andrey Semashev
b4d606cdd0 Reduced preprocessor conditions. 2020-12-23 11:10:50 +03:00
whitequark
c6e5bdafce Update WASI platform support. 2020-12-23 11:10:50 +03:00
Andrey Semashev
cc13e916f9 Added pauses in creation_time_tests to avoid spurious failures on Windows.
Presumably, there's some sort of mismatch between times returned by time()
and file creation timestamps when converted to time_t, which can sometimes
result in a test failure. The pauses ensure there's enough distance
between start, finish and file creation timestamps for the discrepancy
to not matter. Also added debug output.
2020-12-23 10:55:00 +03:00
Andrey Semashev
9cab675b71 Create symlinks in the test directory in the operations tests.
This should resolve spurious test failures due to multiple test instances
interfering with each other by creating and deleting the same symlink.
2020-11-26 01:22:56 +03:00
Andrey Semashev
6c2bf50c3a Fixed space operation on Windows not failing for a non-existing path.
Fixes https://github.com/boostorg/filesystem/issues/167.
2020-11-25 18:15:30 +03:00
Andrey Semashev
6b5e38134a On OpenBSD 4.4 and newer, use statvfs to obtain filesystem space info.
Closes https://github.com/boostorg/filesystem/pull/162.
2020-10-04 15:31:29 +03:00
Andrey Semashev
a5fe695ce3 Force 32-bit address-model on older MSVC versions in AppVeyor CI.
This is to work around the problem of Boost.Build not being able to detect
default address-model when it is 32 (as it is for MSVC 9.0 to 11.0 in
AppVeyor CI). As a result, the build fails because cl.exe cannot be found.

Related to https://github.com/boostorg/build/issues/659.
2020-09-24 03:39:32 +03:00
Andrey Semashev
e260f134d4 Removed const qualification from return types of path methods.
The qualification serves no practical purpose and may prevent optimizations
like move construction or assignment.

Closes https://github.com/boostorg/filesystem/issues/160.
2020-09-23 20:01:04 +03:00
Andrey Semashev
d855c2d377 Enabled C++20 testing for FreeBSD. 2020-08-21 15:12:35 +03:00
Andrey Semashev
fe2a4fea13 Code cleanup to clear clang warnings and remove obsolete code.
Functions for stat/statx abstraction become unused when either of
the two APIs is used, which triggers clang warnings.

Ported copy_directory to statx and removed the BOOST_COPY_DIRECTORY
macro. One less usage of stat().

Removed workarounds for MSVC versions older than 7.0. Use portable
typedef for 64-bit integers.

Marked some internal functions inline. Removed zero initialization
of stat structs prior to stat calls, which is expected to initialize
the struct anyway.
2020-08-21 14:58:21 +03:00
Andrey Semashev
ec64afc0f5 Ported most of the operations to Linux statx system call.
The Linux statx system call allows to specify the data the caller is
interested in. This has the potential of improving performance
if some information is expensive to provide.

Also, changed hard_link_count to return static_cast<uintmax_t>(-1)
in case of errors. Changed file_size to report ENOSYS instead of
EPERM when the operation is invoked on a non-regular file.
2020-08-21 01:33:44 +03:00
Andrey Semashev
8d6eaeb5af Changed returned value of last_write_time in case of error to min std::time_t.
This follows C++20 definition, which returns a minimum representable time
point value in case of error.

Also, slight refactoring of last_write_time setter function and a fix
to ensure the error code is cleared incase of success.
2020-08-21 01:32:17 +03:00
Andrey Semashev
8db5f4edb6 Switch the more recent compiler jobs in Travis CI to Ubuntu Focal.
Ubuntu Focal has a recent enough Linux kernel and glibc to support
statx syscall.

Also switch clang-9 to Ubuntu Bionic and added linux-libc-dev package
installation to test the case when statx is supported by the kernel
but the wrapper in libc is not available.
2020-08-21 01:32:17 +03:00
Andrey Semashev
a031e4ffa9 Added creation_time operation.
The operation allows to query file creation time.

Implementation partially inspired by:

https://github.com/boostorg/filesystem/pull/134

Closes https://github.com/boostorg/filesystem/pull/134.
2020-08-21 01:32:04 +03:00
Andrey Semashev
4748f6e39d Added O_CLOEXEC to open calls in unique_path implementation. 2020-07-29 12:33:15 +03:00