mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
fs: consistently use fsbridge for {i,o}fstream
Part of #20744, but this can be done now, and will simplify the diff.
This commit is contained in:
parent
e3699b71c4
commit
21f781ad79
6 changed files with 7 additions and 7 deletions
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
|
|
||||||
|
#include <fs.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <fstream>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -29,7 +29,7 @@ void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& bench
|
||||||
// nothing to write, bail out
|
// nothing to write, bail out
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::ofstream fout(filename);
|
fsbridge::ofstream fout{fs::PathFromString(filename)};
|
||||||
if (fout.is_open()) {
|
if (fout.is_open()) {
|
||||||
ankerl::nanobench::render(tpl, benchmarkResults, fout);
|
ankerl::nanobench::render(tpl, benchmarkResults, fout);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -158,7 +158,7 @@ void PSBTOperationsDialog::saveTransaction() {
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::ofstream out(filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary);
|
fsbridge::ofstream out{filename.toLocal8Bit().data(), fsbridge::ofstream::out | fsbridge::ofstream::binary};
|
||||||
out << ssTx.str();
|
out << ssTx.str();
|
||||||
out.close();
|
out.close();
|
||||||
showStatus(tr("PSBT saved to disk."), StatusLevel::INFO);
|
showStatus(tr("PSBT saved to disk."), StatusLevel::INFO);
|
||||||
|
|
|
@ -509,7 +509,7 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::ofstream out(filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary);
|
fsbridge::ofstream out{filename.toLocal8Bit().data(), fsbridge::ofstream::out | fsbridge::ofstream::binary};
|
||||||
out << ssTx.str();
|
out << ssTx.str();
|
||||||
out.close();
|
out.close();
|
||||||
Q_EMIT message(tr("PSBT saved"), "PSBT saved to disk", CClientUIInterface::MSG_INFORMATION);
|
Q_EMIT message(tr("PSBT saved"), "PSBT saved to disk", CClientUIInterface::MSG_INFORMATION);
|
||||||
|
|
|
@ -210,7 +210,7 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard)
|
||||||
Q_EMIT message(tr("Error"), tr("PSBT file must be smaller than 100 MiB"), CClientUIInterface::MSG_ERROR);
|
Q_EMIT message(tr("Error"), tr("PSBT file must be smaller than 100 MiB"), CClientUIInterface::MSG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::ifstream in(filename.toLocal8Bit().data(), std::ios::binary);
|
fsbridge::ifstream in{filename.toLocal8Bit().data(), std::ios::binary};
|
||||||
data = std::string(std::istreambuf_iterator<char>{in}, {});
|
data = std::string(std::istreambuf_iterator<char>{in}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ void initialize()
|
||||||
}
|
}
|
||||||
if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) {
|
if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) {
|
||||||
std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl;
|
std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl;
|
||||||
std::ofstream out_stream(out_path, std::ios::binary);
|
fsbridge::ofstream out_stream{out_path, std::ios::binary};
|
||||||
for (const auto& t : FuzzTargets()) {
|
for (const auto& t : FuzzTargets()) {
|
||||||
if (std::get<2>(t.second)) continue;
|
if (std::get<2>(t.second)) continue;
|
||||||
out_stream << t.first << std::endl;
|
out_stream << t.first << std::endl;
|
||||||
|
|
|
@ -146,7 +146,7 @@ bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::streampos GetFileSize(const char* path, std::streamsize max) {
|
std::streampos GetFileSize(const char* path, std::streamsize max) {
|
||||||
std::ifstream file(path, std::ios::binary);
|
fsbridge::ifstream file{path, std::ios::binary};
|
||||||
file.ignore(max);
|
file.ignore(max);
|
||||||
return file.gcount();
|
return file.gcount();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue