Skip to content

Commit 21f781a

Browse files
committed
fs: consistently use fsbridge for {i,o}fstream
Part of #20744, but this can be done now, and will simplify the diff.
1 parent e3699b7 commit 21f781a

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/bench/bench.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#include <bench/bench.h>
66

7+
#include <fs.h>
78
#include <test/util/setup_common.h>
89

910
#include <chrono>
10-
#include <fstream>
1111
#include <functional>
1212
#include <iostream>
1313
#include <map>
@@ -29,7 +29,7 @@ void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& bench
2929
// nothing to write, bail out
3030
return;
3131
}
32-
std::ofstream fout(filename);
32+
fsbridge::ofstream fout{fs::PathFromString(filename)};
3333
if (fout.is_open()) {
3434
ankerl::nanobench::render(tpl, benchmarkResults, fout);
3535
} else {

src/qt/psbtoperationsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void PSBTOperationsDialog::saveTransaction() {
158158
if (filename.isEmpty()) {
159159
return;
160160
}
161-
std::ofstream out(filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary);
161+
fsbridge::ofstream out{filename.toLocal8Bit().data(), fsbridge::ofstream::out | fsbridge::ofstream::binary};
162162
out << ssTx.str();
163163
out.close();
164164
showStatus(tr("PSBT saved to disk."), StatusLevel::INFO);

src/qt/sendcoinsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
509509
if (filename.isEmpty()) {
510510
return;
511511
}
512-
std::ofstream out(filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary);
512+
fsbridge::ofstream out{filename.toLocal8Bit().data(), fsbridge::ofstream::out | fsbridge::ofstream::binary};
513513
out << ssTx.str();
514514
out.close();
515515
Q_EMIT message(tr("PSBT saved"), "PSBT saved to disk", CClientUIInterface::MSG_INFORMATION);

src/qt/walletframe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard)
210210
Q_EMIT message(tr("Error"), tr("PSBT file must be smaller than 100 MiB"), CClientUIInterface::MSG_ERROR);
211211
return;
212212
}
213-
std::ifstream in(filename.toLocal8Bit().data(), std::ios::binary);
213+
fsbridge::ifstream in{filename.toLocal8Bit().data(), std::ios::binary};
214214
data = std::string(std::istreambuf_iterator<char>{in}, {});
215215
}
216216

src/test/fuzz/fuzz.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void initialize()
8080
}
8181
if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) {
8282
std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl;
83-
std::ofstream out_stream(out_path, std::ios::binary);
83+
fsbridge::ofstream out_stream{out_path, std::ios::binary};
8484
for (const auto& t : FuzzTargets()) {
8585
if (std::get<2>(t.second)) continue;
8686
out_stream << t.first << std::endl;

src/util/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes)
146146
}
147147

148148
std::streampos GetFileSize(const char* path, std::streamsize max) {
149-
std::ifstream file(path, std::ios::binary);
149+
fsbridge::ifstream file{path, std::ios::binary};
150150
file.ignore(max);
151151
return file.gcount();
152152
}

0 commit comments

Comments
 (0)