1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class charT, class traits = char_traits<charT> >
13 // class basic_fstream
15 // template <class charT, class traits>
16 // void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
21 #include "platform_support.h"
24 std::pair<std::string, std::string> get_temp_file_names() {
25 std::pair<std::string, std::string> names;
26 names.first = get_temp_file_name();
28 // Create the file so the next call to `get_temp_file_name()` doesn't
29 // return the same file.
30 std::FILE *fd1 = std::fopen(names.first.c_str(), "w");
32 names.second = get_temp_file_name();
33 assert(names.first != names.second);
36 std::remove(names.first.c_str());
43 std::pair<std::string, std::string> temp_files = get_temp_file_names();
44 std::string& temp1 = temp_files.first;
45 std::string& temp2 = temp_files.second;
46 assert(temp1 != temp2);
48 std::fstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
49 | std::ios_base::trunc);
50 std::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
51 | std::ios_base::trunc);
68 std::remove(temp1.c_str());
69 std::remove(temp2.c_str());
71 std::wfstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
72 | std::ios_base::trunc);
73 std::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
74 | std::ios_base::trunc);
91 std::remove(temp1.c_str());
92 std::remove(temp2.c_str());