diff --git a/stl/CMakeLists.txt b/stl/CMakeLists.txt index f399e60c92e..5a17913c29d 100644 --- a/stl/CMakeLists.txt +++ b/stl/CMakeLists.txt @@ -73,7 +73,6 @@ set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/inc/execution ${CMAKE_CURRENT_LIST_DIR}/inc/expected ${CMAKE_CURRENT_LIST_DIR}/inc/experimental/coroutine - ${CMAKE_CURRENT_LIST_DIR}/inc/experimental/filesystem ${CMAKE_CURRENT_LIST_DIR}/inc/experimental/generator ${CMAKE_CURRENT_LIST_DIR}/inc/experimental/resumable ${CMAKE_CURRENT_LIST_DIR}/inc/filesystem diff --git a/stl/inc/__msvc_all_public_headers.hpp b/stl/inc/__msvc_all_public_headers.hpp index ff36108473f..106967a54f6 100644 --- a/stl/inc/__msvc_all_public_headers.hpp +++ b/stl/inc/__msvc_all_public_headers.hpp @@ -29,7 +29,6 @@ #endif // !defined(_SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING) #define _SILENCE_CXX20_CISO646_REMOVED_WARNING -#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING // Core STL Headers #include @@ -155,9 +154,6 @@ #include #include -// Non-Core Experimental Headers -#include - #endif // !defined(_CORE_HEADERS_ONLY) #ifndef _MSVC_TESTING_NVCC diff --git a/stl/inc/__msvc_filebuf.hpp b/stl/inc/__msvc_filebuf.hpp index 7b2846b020c..009265e0a19 100644 --- a/stl/inc/__msvc_filebuf.hpp +++ b/stl/inc/__msvc_filebuf.hpp @@ -18,7 +18,7 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new -// TRANSITION, ABI: The _Path_ish functions accepting filesystem::path or experimental::filesystem::path are templates +// TRANSITION, ABI: The _Path_ish functions accepting filesystem::path are templates // which always use the same types as a workaround for user code deriving from iostreams types and // __declspec(dllexport)ing the derived types. Adding member functions to iostreams broke the ABI of such DLLs. // Deriving and __declspec(dllexport)ing standard library types is not supported, but in this particular case @@ -31,36 +31,6 @@ namespace filesystem { } #endif // _HAS_CXX17 -#ifndef _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM -#ifdef _M_CEE -#define _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM 0 -#else // ^^^ defined(_M_CEE) / !defined(_M_CEE) vvv -#define _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM 1 -#endif // ^^^ !defined(_M_CEE) ^^^ -#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - -#if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM -namespace experimental { - namespace filesystem { - inline namespace v1 { - class path; - } - } // namespace filesystem -} // namespace experimental -#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - -template -constexpr bool _Is_any_path = _Is_any_of_v<_Ty -#if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - , - experimental::filesystem::path -#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM -#if _HAS_CXX17 - , - filesystem::path -#endif // _HAS_CXX17 - >; - extern "C++" _CRTIMP2_PURE FILE* __CLRCALL_PURE_OR_CDECL _Fiopen(const char*, ios_base::openmode, int); extern "C++" _CRTIMP2_PURE FILE* __CLRCALL_PURE_OR_CDECL _Fiopen(const wchar_t*, ios_base::openmode, int); @@ -325,15 +295,6 @@ class basic_filebuf : public basic_streambuf<_Elem, _Traits> { // stream buffer return open(_Str.c_str(), _Mode, _Prot); } -#if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - template - basic_filebuf* open( - const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode, int _Prot = ios_base::_Default_open_prot) { - // _Prot is an extension - return open(_Path.c_str(), _Mode, _Prot); - } -#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - #if _HAS_CXX17 template basic_filebuf* open( diff --git a/stl/inc/fstream b/stl/inc/fstream index bb6060f0cfd..cbae7586dbc 100644 --- a/stl/inc/fstream +++ b/stl/inc/fstream @@ -54,10 +54,12 @@ public: const wstring& _Str, ios_base::openmode _Mode = ios_base::in, int _Prot = ios_base::_Default_open_prot) : basic_ifstream(_Str.c_str(), _Mode, _Prot) {} // extension - template , int> = 0> +#if _HAS_CXX17 + template , int> = 0> explicit basic_ifstream( const _Ty& _Path, ios_base::openmode _Mode = ios_base::in, int _Prot = ios_base::_Default_open_prot) : basic_ifstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension +#endif // _HAS_CXX17 explicit basic_ifstream(FILE* _File) : _Mybase(_STD addressof(_Filebuffer)), _Filebuffer(_File) {} // extension @@ -102,15 +104,6 @@ public: open(_Str.c_str(), _Mode, _Prot); } -#if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - template - void open(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in, - int _Prot = ios_base::_Default_open_prot) { - // _Prot is an extension - open(_Path.c_str(), _Mode, _Prot); - } -#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - #if _HAS_CXX17 template void open(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in, @@ -207,10 +200,12 @@ public: const wstring& _Str, ios_base::openmode _Mode = ios_base::out, int _Prot = ios_base::_Default_open_prot) : basic_ofstream(_Str.c_str(), _Mode, _Prot) {} // extension - template , int> = 0> +#if _HAS_CXX17 + template , int> = 0> explicit basic_ofstream( const _Ty& _Path, ios_base::openmode _Mode = ios_base::out, int _Prot = ios_base::_Default_open_prot) : basic_ofstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension +#endif // _HAS_CXX17 explicit basic_ofstream(FILE* _File) : _Mybase(_STD addressof(_Filebuffer)), _Filebuffer(_File) {} // extension @@ -255,15 +250,6 @@ public: open(_Str.c_str(), _Mode, _Prot); } -#if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - template - void open(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::out, - int _Prot = ios_base::_Default_open_prot) { - // _Prot is an extension - open(_Path.c_str(), _Mode, _Prot); - } -#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - #if _HAS_CXX17 template void open(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::out, @@ -365,10 +351,12 @@ public: int _Prot = ios_base::_Default_open_prot) : basic_fstream(_Str.c_str(), _Mode, _Prot) {} // extension - template , int> = 0> +#if _HAS_CXX17 + template , int> = 0> explicit basic_fstream(const _Ty& _Path, ios_base::openmode _Mode = ios_base::in | ios_base::out, int _Prot = ios_base::_Default_open_prot) : basic_fstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension +#endif // _HAS_CXX17 explicit basic_fstream(FILE* _File) : _Mybase(_STD addressof(_Filebuffer)), _Filebuffer(_File) {} // extension @@ -414,15 +402,6 @@ public: open(_Str.c_str(), _Mode, _Prot); } -#if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - template - void open(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in | ios_base::out, - int _Prot = ios_base::_Default_open_prot) { - // extension - open(_Path.c_str(), _Mode, _Prot); - } -#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - #if _HAS_CXX17 template void open(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in | ios_base::out, @@ -487,8 +466,6 @@ void swap(basic_fstream<_Elem, _Traits>& _Left, basic_fstream<_Elem, _Traits>& _ } _STD_END -#undef _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM - #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS #pragma warning(pop) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 50d1fe59839..dc18e28519e 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1911,8 +1911,6 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #define __cpp_lib_variant 202102L // P2162R2 Inheriting From variant #endif -#define __cpp_lib_experimental_filesystem 201406L - #ifdef _RTC_CONVERSION_CHECKS_ENABLED #ifndef _ALLOW_RTCc_IN_STL #error /RTCc rejects conformant code, so it is not supported by the C++ Standard Library. Either remove this \ diff --git a/stl/src/filesys.cpp b/stl/src/filesys.cpp index ee8a061383e..eff04e50ff6 100644 --- a/stl/src/filesys.cpp +++ b/stl/src/filesys.cpp @@ -4,17 +4,32 @@ // filesys.cpp -- implementation // (see filesystem.cpp for C++17 implementation) -#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +// TRANSITION, ABI: Everything in this file is preserved for binary compatibility. #include +#include #include #include -#include #include +#include #include +#define _MAX_FILESYS_NAME 260 // longest Windows or Posix filename + 1 + +#define _FS_BEGIN \ + _STD_BEGIN \ + namespace experimental { \ + namespace filesystem { \ + inline namespace v1 { + +#define _FS_END \ + } \ + } \ + } \ + _STD_END + #ifdef _M_CEE_PURE #define __crtGetTempPath2W(BufferLength, Buffer) GetTempPathW(BufferLength, Buffer) #else // vvv !defined(_M_CEE_PURE) vvv @@ -23,6 +38,53 @@ extern "C" _Success_(return > 0 && return < BufferLength) DWORD __stdcall __crtG #endif // ^^^ !defined(_M_CEE_PURE) ^^^ _FS_BEGIN + +enum class file_type { // names for file types + not_found = -1, + none, + regular, + directory, + symlink, + block, + character, + fifo, + socket, + unknown +}; + +enum class perms { // names for permissions + none = 0, + owner_read = 0400, // S_IRUSR + owner_write = 0200, // S_IWUSR + owner_exec = 0100, // S_IXUSR + owner_all = 0700, // S_IRWXU + group_read = 040, // S_IRGRP + group_write = 020, // S_IWGRP + group_exec = 010, // S_IXGRP + group_all = 070, // S_IRWXG + others_read = 04, // S_IROTH + others_write = 02, // S_IWOTH + others_exec = 01, // S_IXOTH + others_all = 07, // S_IRWXO + all = 0777, + set_uid = 04000, // S_ISUID + set_gid = 02000, // S_ISGID + sticky_bit = 01000, // S_ISVTX + mask = 07777, + unknown = 0xFFFF, + add_perms = 0x10000, + remove_perms = 0x20000, + resolve_symlinks = 0x40000 +}; + +_BITMASK_OPS(_EMPTY_ARGUMENT, perms) + +struct space_info { // space information for a file + uintmax_t capacity; + uintmax_t free; + uintmax_t available; +}; + static file_type _Map_mode(int _Mode) { // map Windows file attributes to file_status constexpr int _File_attribute_regular = FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_ENCRYPTED | FILE_ATTRIBUTE_HIDDEN diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 4dbf0183b83..46d37feb872 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // filesystem.cpp -- C++17 implementation -// (see filesys.cpp for implementation) #include #include diff --git a/stl/inc/experimental/filesystem b/tests/std/include/experimental_filesystem.hpp similarity index 96% rename from stl/inc/experimental/filesystem rename to tests/std/include/experimental_filesystem.hpp index dffae927880..e9bd384243d 100644 --- a/stl/inc/experimental/filesystem +++ b/tests/std/include/experimental_filesystem.hpp @@ -3,6 +3,12 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// ******************************************************************************************************************** +// * This was previously shipped in product code as . * +// * It's now preserved in cryostasis for test code to exercise functions that are retained for binary compatibility. * +// * This file should generally not be changed, except to fix compiler warnings/errors and to update clang-format. * +// ******************************************************************************************************************** + #ifndef _EXPERIMENTAL_FILESYSTEM_ #define _EXPERIMENTAL_FILESYSTEM_ #include diff --git a/tests/std/tests/Dev09_172666_tr1_tuple_odr/test.cpp b/tests/std/tests/Dev09_172666_tr1_tuple_odr/test.cpp index c57ae88c8be..203ade46b08 100644 --- a/tests/std/tests/Dev09_172666_tr1_tuple_odr/test.cpp +++ b/tests/std/tests/Dev09_172666_tr1_tuple_odr/test.cpp @@ -1,26 +1,31 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING + #include <__msvc_all_public_headers.hpp> #include -namespace fs = std::experimental::filesystem; +#include "experimental_filesystem.hpp" int meow(); -inline bool test_wchar_t_minus() { - // Test for DevDiv-1004799: : /Zc:wchar_t- fails. Calling file_size - // should cause the failure to occur if we are wchar_t incorrect. Test is disabled - // (i.e. always passes) if compiled with /clr:pure and /Zc:wchar_t-, as it triggers - // LNK2031: calling convention missing in metadata errors, which are irrelevant here. -#if defined(_M_CEE_PURE) && !defined(_NATIVE_WCHAR_T_DEFINED) - return true; -#else // ^^^ /clr:pure /Zc:wchar_t- / Other vvv - return fs::file_size(fs::current_path() / "Dev09_172666_tr1_tuple_odr.exe") != 0u; -#endif // defined(_M_CEE_PURE) && !defined(_NATIVE_WCHAR_T_DEFINED) -} - int main() { assert(meow() == 1729); - assert(test_wchar_t_minus()); + + // Test for DevDiv-1004799: : /Zc:wchar_t- fails. + // Calling file_size should cause the failure to occur if we are wchar_t incorrect. +#if defined(_M_CEE_PURE) && !defined(_NATIVE_WCHAR_T_DEFINED) + // Test is disabled if compiled with /clr:pure and /Zc:wchar_t-, as it triggers + // LNK2031: calling convention missing in metadata errors, which are irrelevant here. +#else // ^^^ workaround / no workaround vvv + { + namespace fs = std::experimental::filesystem; + assert(fs::file_size(fs::current_path() / "Dev09_172666_tr1_tuple_odr.exe") != 0u); + } + +#if _HAS_CXX17 + assert(std::filesystem::file_size(std::filesystem::current_path() / "Dev09_172666_tr1_tuple_odr.exe") != 0u); +#endif // _HAS_CXX17 +#endif // ^^^ no workaround ^^^ } diff --git a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp index b548e3d443d..60ba4716aeb 100644 --- a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp +++ b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -31,6 +30,8 @@ #include #endif // _HAS_CXX20 +#include "experimental_filesystem.hpp" + using namespace std; // N3797 24.2.5 [forward.iterators]/2: diff --git a/tests/std/tests/Dev11_1066931_filesystem_rename_noop/test.cpp b/tests/std/tests/Dev11_1066931_filesystem_rename_noop/test.cpp index a21fb335a6f..7d02f077bad 100644 --- a/tests/std/tests/Dev11_1066931_filesystem_rename_noop/test.cpp +++ b/tests/std/tests/Dev11_1066931_filesystem_rename_noop/test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -16,6 +15,7 @@ #include #endif // _HAS_CXX17 +#include "experimental_filesystem.hpp" #include using namespace std; diff --git a/tests/std/tests/Dev11_1180290_filesystem_error_code/test.cpp b/tests/std/tests/Dev11_1180290_filesystem_error_code/test.cpp index 24abba9e72b..bc8b89c6320 100644 --- a/tests/std/tests/Dev11_1180290_filesystem_error_code/test.cpp +++ b/tests/std/tests/Dev11_1180290_filesystem_error_code/test.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -14,6 +13,8 @@ #include #endif // _HAS_CXX17 +#include "experimental_filesystem.hpp" + using namespace std; using namespace std::chrono; diff --git a/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp b/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp index 564ae410552..40ff63d4013 100644 --- a/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp +++ b/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp @@ -105,8 +105,7 @@ #include #endif // _M_CEE_PURE -#include - +#include "experimental_filesystem.hpp" #include diff --git a/tests/std/tests/VSO_0000000_path_stream_parameter/test.cpp b/tests/std/tests/VSO_0000000_path_stream_parameter/test.cpp index dcdbc072202..1a9f7fb25c2 100644 --- a/tests/std/tests/VSO_0000000_path_stream_parameter/test.cpp +++ b/tests/std/tests/VSO_0000000_path_stream_parameter/test.cpp @@ -4,11 +4,11 @@ #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include -#include #include #include #include +#include "experimental_filesystem.hpp" #include using namespace std; diff --git a/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp b/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp index a35303fde30..17517082f0b 100644 --- a/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp +++ b/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp @@ -8,10 +8,11 @@ #include #include #include -#include #include #include +#include "experimental_filesystem.hpp" + using namespace std; namespace fs = std::experimental::filesystem; diff --git a/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp b/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp index 1f88a25ff9c..fe5fbd82a9a 100644 --- a/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp +++ b/tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp @@ -345,8 +345,6 @@ STATIC_ASSERT(__cpp_lib_expected == 202211L); #error __cpp_lib_expected is defined #endif -STATIC_ASSERT(__cpp_lib_experimental_filesystem == 201406L); - #if _HAS_CXX17 STATIC_ASSERT(__cpp_lib_filesystem == 201703L); #elif defined(__cpp_lib_filesystem) diff --git a/tests/std/tests/include_each_header_alone_matrix.lst b/tests/std/tests/include_each_header_alone_matrix.lst index 7521d9ae009..0071e4b15bc 100644 --- a/tests/std/tests/include_each_header_alone_matrix.lst +++ b/tests/std/tests/include_each_header_alone_matrix.lst @@ -118,4 +118,3 @@ PM_CL="/DMEOW_HEADER=ctime" PM_CL="/DMEOW_HEADER=cuchar" PM_CL="/DMEOW_HEADER=cwchar" PM_CL="/DMEOW_HEADER=cwctype" -PM_CL="/DMEOW_HEADER=experimental/filesystem /D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING" diff --git a/tests/tr1/tests/filesystem1/test.cpp b/tests/tr1/tests/filesystem1/test.cpp index 1a79e04fc19..1f7f78eba93 100644 --- a/tests/tr1/tests/filesystem1/test.cpp +++ b/tests/tr1/tests/filesystem1/test.cpp @@ -7,10 +7,11 @@ #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include "tdefs.h" -#include #include #include +#include "experimental_filesystem.hpp" + #define TMP_NAME(suf) "tmp_name" suf #define CHECK_TBL(str, field) CHECK_STRING(native_to_char(str), fix_bslash(STD string(field)))