Skip to content

Commit a554cc9

Browse files
committed
Move boost/std fstream to fsbridge
1 parent 86eb3b3 commit a554cc9

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

src/qt/guiutil.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ bool openBitcoinConf()
367367
fs::path pathConfig = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
368368

369369
/* Create the file */
370-
fs::ofstream configFile(pathConfig, std::ios_base::app);
370+
fsbridge::ofstream configFile(pathConfig, std::ios_base::app);
371371

372372
if (!configFile.good())
373373
return false;
@@ -611,7 +611,7 @@ fs::path static GetAutostartFilePath()
611611

612612
bool GetStartOnSystemStartup()
613613
{
614-
fs::ifstream optionFile(GetAutostartFilePath());
614+
fsbridge::ifstream optionFile(GetAutostartFilePath());
615615
if (!optionFile.good())
616616
return false;
617617
// Scan through file for "Hidden=true":
@@ -642,7 +642,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
642642

643643
fs::create_directories(GetAutostartDir());
644644

645-
fs::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out|std::ios_base::trunc);
645+
fsbridge::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc);
646646
if (!optionFile.good())
647647
return false;
648648
std::string chain = gArgs.GetChainName();

src/rpc/protocol.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <utiltime.h>
1313
#include <version.h>
1414

15-
#include <fstream>
16-
1715
/**
1816
* JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility,
1917
* but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
@@ -85,9 +83,9 @@ bool GenerateAuthCookie(std::string *cookie_out)
8583
/** the umask determines what permissions are used to create this file -
8684
* these are set to 077 in init.cpp unless overridden with -sysperms.
8785
*/
88-
std::ofstream file;
86+
fsbridge::ofstream file;
8987
fs::path filepath_tmp = GetAuthCookieFile(true);
90-
file.open(filepath_tmp.string().c_str());
88+
file.open(filepath_tmp);
9189
if (!file.is_open()) {
9290
LogPrintf("Unable to open cookie authentication file %s for writing\n", filepath_tmp.string());
9391
return false;
@@ -109,10 +107,10 @@ bool GenerateAuthCookie(std::string *cookie_out)
109107

110108
bool GetAuthCookie(std::string *cookie_out)
111109
{
112-
std::ifstream file;
110+
fsbridge::ifstream file;
113111
std::string cookie;
114112
fs::path filepath = GetAuthCookieFile();
115-
file.open(filepath.string().c_str());
113+
file.open(filepath);
116114
if (!file.is_open())
117115
return false;
118116
std::getline(file, cookie);

src/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
891891
}
892892

893893
const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
894-
fs::ifstream stream(GetConfigFile(confPath));
894+
fsbridge::ifstream stream(GetConfigFile(confPath));
895895

896896
// ok to not have a config file
897897
if (stream.good()) {
@@ -924,7 +924,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
924924
}
925925

926926
for (const std::string& to_include : includeconf) {
927-
fs::ifstream include_config(GetConfigFile(to_include));
927+
fsbridge::ifstream include_config(GetConfigFile(to_include));
928928
if (include_config.good()) {
929929
if (!ReadConfigStream(include_config, error, ignore_invalid_keys)) {
930930
return false;

src/wallet/rpcdump.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include <wallet/rpcwallet.h>
1919

20-
#include <fstream>
2120
#include <stdint.h>
2221

2322
#include <boost/algorithm/string.hpp>
@@ -540,8 +539,8 @@ UniValue importwallet(const JSONRPCRequest& request)
540539

541540
EnsureWalletIsUnlocked(pwallet);
542541

543-
std::ifstream file;
544-
file.open(request.params[0].get_str().c_str(), std::ios::in | std::ios::ate);
542+
fsbridge::ifstream file;
543+
file.open(request.params[0].get_str(), std::ios::in | std::ios::ate);
545544
if (!file.is_open()) {
546545
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
547546
}
@@ -717,8 +716,8 @@ UniValue dumpwallet(const JSONRPCRequest& request)
717716
throw JSONRPCError(RPC_INVALID_PARAMETER, filepath.string() + " already exists. If you are sure this is what you want, move it out of the way first");
718717
}
719718

720-
std::ofstream file;
721-
file.open(filepath.string().c_str());
719+
fsbridge::ofstream file;
720+
file.open(filepath);
722721
if (!file.is_open())
723722
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
724723

0 commit comments

Comments
 (0)