From 5d16e6bd00d1e75be52a319bd8ad969a333d1e0f Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Tue, 18 Jun 2024 21:03:51 +0300 Subject: [PATCH] Fixed file_size and is_empty for symlinks on Windows. Reworked is_empty. GetFileAttributesExW that was used to implement file_size and is_empty on Windows returns information about the symlink rather than the file the symlink refers to. Fix this by opening the file and using GetFileInformationByHandle to obtain the file size and attributes. Additionally, reworked is_empty implementation to reuse the file handle (and fd on POSIX systems) to create the directory iterator if the operation is invoked on a directory. On POSIX systems, implement a more lightweight version of is_empty_directory when readdir is safe to use. Reusing the file handle/fd improves protection against filesystem races, when the file that is being tested by is_empty is initially a directory and then, when we create a directory iterator, it is not. Fixes https://github.com/boostorg/filesystem/issues/313. --- doc/release_history.html | 7 ++ src/directory.cpp | 94 +++++++++++++++++++++- src/operations.cpp | 164 +++++++++++++++++++++++++++------------ test/operations_test.cpp | 101 ++++++++++++++++++++++++ 4 files changed, 315 insertions(+), 51 deletions(-) diff --git a/doc/release_history.html b/doc/release_history.html index b6cceddb3..b3410fc13 100644 --- a/doc/release_history.html +++ b/doc/release_history.html @@ -40,6 +40,13 @@ +

1.86.0

+ +

1.85.0