libstdc++ starting 8.1.0 in C++17 mode support std::filesystem and is able to
open the file streams with std::filesystem::path constructible from wide
strings.
libc++ starting 7.0 also supports std::filesystem::path in C++17 mode and may
also support passing `const wchar_t*` strings to open files.
Closes https://github.com/boostorg/filesystem/issues/181.
Filenames starting with a dot (and no other dots) are commonly treated
as filenames with no extension rather than an extension. This is also
the behavior mandated in C++17 filesystem.
Reported in https://github.com/boostorg/filesystem/issues/88.
The print name can be empty for some reparse points (e.g. mount points
created by Box cloud storage driver and directory junctions created by
junction.exe). It is supposed to be mostly used for presenting a "simple"
path to the user and not to actually locate the file.
The substitute name is the actionable replacement path, but it is in
NT path format and can potentially point to unmounted volumes and
UNC resources. The implementation attempts to convert the NT path
to Win32 path by matching commonly known patterns against the NT path.
If no pattern matches, we create a Win32 path by converting the NT path
prefix to "\\?\".
Related to https://github.com/boostorg/filesystem/issues/187.
The new implementation is also not relying on the root name format and
is more pertormant as it avoids unnecessarily copying path elements during
operation.
Note that this commit does not remove the trailing dot elements in the
normalized paths.
- Unified root name and root directory parsing that was scattered and
duplicated across different algorithms. The new implementation is
consolidated in a single function for parsing root name and root
directory, which is used from various algorithms.
- The new root name parsing now supports Windows local device ("\\.\")
and NT path ("\??\") prefixes. It also adds support for filesystem
("\\?\") prefix to some of the higher level algorithms that were
using custom parsing previously. Tests updated to verify these prefixes.
- Some of the path decomposition methods were unified with presence checking
methods (e.g. root_name with has_root_name). This makes these methods
work consistently and also makes the has_* methods less expensive as
they no longer have to construct a path only to check if it is empty.
- The filename accessor no longer returns root name if the whole path
only consists of a root name. This also affects stem and extension as
those accessors are based on filename. This is a breaking change.
- Cleaned up code:
- Removed redundant checks for std::wstring support.
- Added header/footer headers to globally disable compiler warnings.
- Removed commented out super-deprecated code.
- Added missing includes and removed includes that are not needed.
- Nonessential code formatting.
Avoid creating root directory path only to test if it's empty. Avoid
calling root_directory multiple times in root_path.
Also, nonessential code reformatting.
When current_path on POSIX falls back to the dynamically allocated
buffer for the resulting path, start with double the size of the
small stack buffer that was used initially.
When canonical() resolves symlink, it is possible that a symlink resolves
to an absolute path with a different root. We need to update the root
path so that when we restart symlink resolution the check for the
root path still works.
Also, slightly refactored the canonical() implementation to reduce code
size and possibly optimize the generated code.
This forces definition of _WIN32_WINNT by Boost.WinAPI, which is important
for CopyFileEx and related symbols to be defined. Platform SDK from MSVC-8
does not define the macro by default, which caused compilation errors
previously.
There was a missing calling convention specification in the CopyFileEx
callback. This was not a problem in 64-bit builds since there is no
stdcall convention in 64-bit x86.
When CopyFileEx copies multi-stream files, the callback is executed for each
stream separately. Each stream is represented with a separate file handle,
so we have to flush buffers when the stream is fully copied, rather than the
whole file.
Use FlushFileBuffers to force any buffered data written to the permanent
storage. The previously used COPY_FILE_NO_BUFFERING flag only guarantees
that no data is left in the OS filesystem cache, but does not ensure
that any device buffers are flushed.
In single-threaded builds we can assume no thread synchronization
is necessary and avoid the dependency on Boost.Atomic. The dependency
caused single-threaded build failures because Boost.Atomic requires
multithreading to be enabled.
The CMake build currently does not support single-threaded builds, so
the dependency is left present there.
Closes https://github.com/boostorg/filesystem/issues/188.
The buffer size is now selected based on the file size and filesystem block
size and is limited with min and max. This allows to reduce memory consumption
and possibly increase performance when copying smaller files.