The copy_file operation implementation has been inlined into the
detail::copy_file function. The part that copies the file body has been
extracted to a separate function, so that addition of specialized copy
implementations later is possible.
Added copy_options enum, which reflects the enum from C++20. Currently,
only overwrite_existing option is supported. Other options will be added
later.
The old enum copy_option is deprecated in favor of copy_options.
Updated docs to reflect recent changes to copy_file behavior.
space() now initializes space_info members to -1 values, which is used when the
structure is returned in case of error.
On Windows, check if the path refers to a directory, and use the parent
directory if not. In order to make sure we return space information for the
target filesystem, we have to resolve symlinks in this case.
Fixes https://github.com/boostorg/filesystem/issues/73.
Since max size of the REPARSE_DATA_BUFFER structure (with the variable storage)
is quite large, it makes sense to dynamically allocate it rather than store it
on the stack.
For some unknown reason, Windows 8.1 system shell returns error code 1 when
invoking mklink to test if it exists. To work around this we now analyze
output of the command in the Jamfile. As an added bonus, the test is not
compiled when mklink is not supported.
Read access to the file does not seem to be needed to read the reparse point,
so dropping it works in favor of reducing the likelihood of a sharing violation.
This ensures that the files overwritten or created by copy_file have the same
permission bits as the source file, as required by C++20. Also, for the duration
of the copy operation we ensure the target file has writing permission set.
This is important e.g. for NFS, which checks the permission on the server,
so a writable file descriptor on the client is not enough for the write
operation to succeed.
Notably, this doesn't save the case of overwriting the file with no write
permission set. In this case the operation will fail with EPERM.
Also, use fsync/fdatasync to guarantee that the target file is written
completely without errors before closing the file descriptor.
The POSIX copy_file implementation has beed reworked to perform checks for
whether the source and target files are regilar files and whether the source
and target paths identify the same file. Also, the implementation has been fixed
to report the correct error code from the failed operation to the caller
in case of failure. The implementation is now also protected against EINTR
errors and uses O_CLOEXEC when possible to avoid leaking file descriptors
if the caller process forks.
Also, the file equivalence test is now simplified to not test the file size
and last modification time. These tests had a potential of causing a false
negative, if the file that is being tested was modified between the stat()
calls that were used to obtain file information from the paths.
Closes https://github.com/boostorg/filesystem/pull/48.
Often enough the API functions are available and the runtime checks do
detect those well enough, so don't cripple the functionality just
because the user forget to define a reasonable API level (default is
often even less then WinXP)
When stat() failed for both paths passed to equivalent(), the latter
would set an invalid error code of 1 instead of errno before returning.
Use one of the error codes returned by stat() to set the error_code.
Also changed Windows variant of equivalent() to report the actual
Windows error code for the failed operation of creating a file handle.
Fixes https://github.com/boostorg/filesystem/issues/141.