diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 122d11879bc..c0d298d2e1b 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -110,6 +110,7 @@ add_benchmark(adjacent_difference src/adjacent_difference.cpp) add_benchmark(bitset_from_string src/bitset_from_string.cpp) add_benchmark(bitset_to_string src/bitset_to_string.cpp) add_benchmark(efficient_nonlocking_print src/efficient_nonlocking_print.cpp) +add_benchmark(filesystem src/filesystem.cpp) add_benchmark(find_and_count src/find_and_count.cpp) add_benchmark(find_first_of src/find_first_of.cpp) add_benchmark(iota src/iota.cpp) diff --git a/benchmarks/src/filesystem.cpp b/benchmarks/src/filesystem.cpp new file mode 100644 index 00000000000..33c8e69e875 --- /dev/null +++ b/benchmarks/src/filesystem.cpp @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +void symlink_status(benchmark::State& state) { + const auto path = std::filesystem::temp_directory_path(); + + for (auto _ : state) { + std::error_code ec; + benchmark::DoNotOptimize(path); + const auto status = std::filesystem::symlink_status(path, ec); + benchmark::DoNotOptimize(status); + benchmark::DoNotOptimize(ec); + } +} + +BENCHMARK(symlink_status); + +BENCHMARK_MAIN(); diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 4ea23edc592..ba05446a1d7 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -900,6 +900,13 @@ namespace { _Flags &= ~_Get_file_attributes_data; } + + if (!_STD _Bitmask_includes_any(_Attributes, __std_fs_file_attr::_Reparse_point) + && _STD _Bitmask_includes_any(_Flags, __std_fs_stats_flags::_Reparse_tag)) { + // if reparse tag is requested by caller but the file is not a reparse point, set tag to _None + _Stats->_Reparse_point_tag = __std_fs_reparse_tag::_None; + _Flags &= ~__std_fs_stats_flags::_Reparse_tag; + } } }