File tree 2 files changed +10
-9
lines changed
2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,20 @@ namespace tmp {
8
8
namespace {
9
9
10
10
// / Opens a temporary file for writing and returns an output file stream
11
- // / @param file The file to open
12
- // / @param binary Whether to open the file in binary mode (true) or text mode (false)
13
- // / @param append Whether to append to the end of the file (true) or truncate it (false)
11
+ // / @param file The file to open
12
+ // / @param binary Whether to open the file in binary mode
13
+ // / @param append Whether to append to the end of the file
14
14
// / @return An output file stream
15
15
std::ofstream stream (const file& file, bool binary, bool append) noexcept {
16
16
std::ios::openmode mode = append ? std::ios::app : std::ios::trunc ;
17
- auto path = static_cast <const std::filesystem::path&>(file);
18
- return binary
19
- ? std::ofstream { path, mode | std::ios::binary }
20
- : std::ofstream { path, mode };
21
- }
17
+ if (binary) {
18
+ mode |= std::ios::binary;
19
+ }
20
+
21
+ const std::filesystem::path& path = file;
22
+ return std::ofstream { path, mode };
22
23
}
24
+ } // namespace
23
25
24
26
file::file (std::string_view prefix) : file(prefix, /* binary=*/ true ) {
25
27
}
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ void remove(const tmp::path& path) noexcept {
14
14
std::filesystem::remove_all (path, ec);
15
15
}
16
16
}
17
-
18
17
} // namespace
19
18
20
19
namespace tmp {
You can’t perform that action at this time.
0 commit comments