[libcxx-commits] [libcxx] [libcxx] Caches file attributes during directory iteration. (PR #93316)
Eduard Satdarov via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 30 10:24:48 PDT 2024
================
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: can-create-symlinks
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: no-filesystem
+// UNSUPPORTED: availability-filesystem-missing
+
+// <filesystem>
+
+// recursive_directory_iterator
+
+#include <filesystem>
+#include <type_traits>
+#include <set>
+#include <cassert>
+
+#include "test_macros.h"
+#include "filesystem_test_helper.h"
+namespace fs = std::filesystem;
+using namespace fs;
+
+#if defined(_WIN32)
+static void set_last_write_time_in_iteration(const fs::path& dir)
+{
+ // Windows can postpone updating last write time for file especially for
+ // directory because last write time of directory depends of its childs.
+ // See
+ // https://learn.microsoft.com/en-us/windows/win32/sysinfo/file-times
+ // To force updating file entries calls "last_write_time" with own value.
----------------
ed-sat wrote:
@EricWF, please, take a look onto this point.
As learn.microsoft.com says, FindFirstFile / FindNextFile can give outdated mtime for directories, unless it's explicitly touched by certain side call
(e. g. GetFileInformationByHandle() or Mark Russinovich File Monitor).
Here we decided to follow microsoft/STL way of handling this issue (that is, do nothing and return / cache whatever is returned by the API).
https://github.com/llvm/llvm-project/pull/93316
More information about the libcxx-commits
mailing list