mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#24167: consistently use fsbridge:: for ifstream / ofstream
This commit is contained in:
parent
7ffea4348f
commit
be7ac493d0
@ -5,11 +5,11 @@
|
|||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
|
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
|
#include <fs.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <assert.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
@ -23,7 +23,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 {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <consensus/consensus.h>
|
#include <consensus/consensus.h>
|
||||||
#include <core_io.h>
|
#include <core_io.h>
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
|
#include <fs.h>
|
||||||
#include <policy/policy.h>
|
#include <policy/policy.h>
|
||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
@ -162,7 +163,7 @@ static void RegisterLoad(const std::string& strInput)
|
|||||||
std::string key = strInput.substr(0, pos);
|
std::string key = strInput.substr(0, pos);
|
||||||
std::string filename = strInput.substr(pos + 1, std::string::npos);
|
std::string filename = strInput.substr(pos + 1, std::string::npos);
|
||||||
|
|
||||||
FILE *f = fopen(filename.c_str(), "r");
|
FILE *f = fsbridge::fopen(filename.c_str(), "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
std::string strErr = "Cannot open file " + filename;
|
std::string strErr = "Cannot open file " + filename;
|
||||||
throw std::runtime_error(strErr);
|
throw std::runtime_error(strErr);
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string>
|
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -20,6 +19,9 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace fsbridge {
|
namespace fsbridge {
|
||||||
|
|
||||||
FILE *fopen(const fs::path& p, const char *mode)
|
FILE *fopen(const fs::path& p, const char *mode)
|
||||||
|
@ -150,7 +150,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);
|
||||||
|
@ -521,7 +521,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);
|
||||||
|
@ -285,7 +285,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}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,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;
|
||||||
|
@ -879,7 +879,7 @@ BOOST_AUTO_TEST_CASE(script_build)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UPDATE_JSON_TESTS
|
#ifdef UPDATE_JSON_TESTS
|
||||||
FILE* file = fopen("script_tests.json.gen", "w");
|
FILE* file = fsbridge::fopen("script_tests.json.gen", "w");
|
||||||
fputs(strGen.c_str(), file);
|
fputs(strGen.c_str(), file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
#endif
|
#endif
|
||||||
|
@ -167,7 +167,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…
Reference in New Issue
Block a user