1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14 10 // UNSUPPORTED: libcpp-has-no-filesystem-library 11 12 // Filesystem is supported on Apple platforms starting with macosx10.15. 13 // UNSUPPORTED: with_system_cxx_lib=macosx10.14 14 // UNSUPPORTED: with_system_cxx_lib=macosx10.13 15 // UNSUPPORTED: with_system_cxx_lib=macosx10.12 16 // UNSUPPORTED: with_system_cxx_lib=macosx10.11 17 // UNSUPPORTED: with_system_cxx_lib=macosx10.10 18 // UNSUPPORTED: with_system_cxx_lib=macosx10.9 19 20 // <fstream> 21 22 // plate <class charT, class traits = char_traits<charT> > 23 // class basic_fstream 24 25 // explicit basic_fstream(const filesystem::path& s, 26 // ios_base::openmode mode = ios_base::in|ios_base::out); 27 28 #include <fstream> 29 #include <filesystem> 30 #include <cassert> 31 #include "test_macros.h" 32 #include "platform_support.h" 33 34 namespace fs = std::filesystem; 35 36 int main(int, char**) { 37 fs::path p = get_temp_file_name(); 38 { 39 std::fstream fs(p, std::ios_base::in | std::ios_base::out | 40 std::ios_base::trunc); 41 double x = 0; 42 fs << 3.25; 43 fs.seekg(0); 44 fs >> x; 45 assert(x == 3.25); 46 } 47 std::remove(p.string().c_str()); 48 { 49 std::wfstream fs(p, std::ios_base::in | std::ios_base::out | 50 std::ios_base::trunc); 51 double x = 0; 52 fs << 3.25; 53 fs.seekg(0); 54 fs >> x; 55 assert(x == 3.25); 56 } 57 std::remove(p.string().c_str()); 58 59 return 0; 60 } 61