Move boost/std fstream to fsbridge
This commit is contained in:
parent
86eb3b3f1a
commit
a554cc901a
4 changed files with 13 additions and 16 deletions
|
@ -367,7 +367,7 @@ bool openBitcoinConf()
|
||||||
fs::path pathConfig = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
|
fs::path pathConfig = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
|
||||||
|
|
||||||
/* Create the file */
|
/* Create the file */
|
||||||
fs::ofstream configFile(pathConfig, std::ios_base::app);
|
fsbridge::ofstream configFile(pathConfig, std::ios_base::app);
|
||||||
|
|
||||||
if (!configFile.good())
|
if (!configFile.good())
|
||||||
return false;
|
return false;
|
||||||
|
@ -611,7 +611,7 @@ fs::path static GetAutostartFilePath()
|
||||||
|
|
||||||
bool GetStartOnSystemStartup()
|
bool GetStartOnSystemStartup()
|
||||||
{
|
{
|
||||||
fs::ifstream optionFile(GetAutostartFilePath());
|
fsbridge::ifstream optionFile(GetAutostartFilePath());
|
||||||
if (!optionFile.good())
|
if (!optionFile.good())
|
||||||
return false;
|
return false;
|
||||||
// Scan through file for "Hidden=true":
|
// Scan through file for "Hidden=true":
|
||||||
|
@ -642,7 +642,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
|
|
||||||
fs::create_directories(GetAutostartDir());
|
fs::create_directories(GetAutostartDir());
|
||||||
|
|
||||||
fs::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out|std::ios_base::trunc);
|
fsbridge::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc);
|
||||||
if (!optionFile.good())
|
if (!optionFile.good())
|
||||||
return false;
|
return false;
|
||||||
std::string chain = gArgs.GetChainName();
|
std::string chain = gArgs.GetChainName();
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include <utiltime.h>
|
#include <utiltime.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility,
|
* JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility,
|
||||||
* but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
|
* 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)
|
||||||
/** the umask determines what permissions are used to create this file -
|
/** the umask determines what permissions are used to create this file -
|
||||||
* these are set to 077 in init.cpp unless overridden with -sysperms.
|
* these are set to 077 in init.cpp unless overridden with -sysperms.
|
||||||
*/
|
*/
|
||||||
std::ofstream file;
|
fsbridge::ofstream file;
|
||||||
fs::path filepath_tmp = GetAuthCookieFile(true);
|
fs::path filepath_tmp = GetAuthCookieFile(true);
|
||||||
file.open(filepath_tmp.string().c_str());
|
file.open(filepath_tmp);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
LogPrintf("Unable to open cookie authentication file %s for writing\n", filepath_tmp.string());
|
LogPrintf("Unable to open cookie authentication file %s for writing\n", filepath_tmp.string());
|
||||||
return false;
|
return false;
|
||||||
|
@ -109,10 +107,10 @@ bool GenerateAuthCookie(std::string *cookie_out)
|
||||||
|
|
||||||
bool GetAuthCookie(std::string *cookie_out)
|
bool GetAuthCookie(std::string *cookie_out)
|
||||||
{
|
{
|
||||||
std::ifstream file;
|
fsbridge::ifstream file;
|
||||||
std::string cookie;
|
std::string cookie;
|
||||||
fs::path filepath = GetAuthCookieFile();
|
fs::path filepath = GetAuthCookieFile();
|
||||||
file.open(filepath.string().c_str());
|
file.open(filepath);
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
return false;
|
return false;
|
||||||
std::getline(file, cookie);
|
std::getline(file, cookie);
|
||||||
|
|
|
@ -891,7 +891,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
|
const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
|
||||||
fs::ifstream stream(GetConfigFile(confPath));
|
fsbridge::ifstream stream(GetConfigFile(confPath));
|
||||||
|
|
||||||
// ok to not have a config file
|
// ok to not have a config file
|
||||||
if (stream.good()) {
|
if (stream.good()) {
|
||||||
|
@ -924,7 +924,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::string& to_include : includeconf) {
|
for (const std::string& to_include : includeconf) {
|
||||||
fs::ifstream include_config(GetConfigFile(to_include));
|
fsbridge::ifstream include_config(GetConfigFile(to_include));
|
||||||
if (include_config.good()) {
|
if (include_config.good()) {
|
||||||
if (!ReadConfigStream(include_config, error, ignore_invalid_keys)) {
|
if (!ReadConfigStream(include_config, error, ignore_invalid_keys)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include <wallet/rpcwallet.h>
|
#include <wallet/rpcwallet.h>
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
@ -540,8 +539,8 @@ UniValue importwallet(const JSONRPCRequest& request)
|
||||||
|
|
||||||
EnsureWalletIsUnlocked(pwallet);
|
EnsureWalletIsUnlocked(pwallet);
|
||||||
|
|
||||||
std::ifstream file;
|
fsbridge::ifstream file;
|
||||||
file.open(request.params[0].get_str().c_str(), std::ios::in | std::ios::ate);
|
file.open(request.params[0].get_str(), std::ios::in | std::ios::ate);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
||||||
}
|
}
|
||||||
|
@ -717,8 +716,8 @@ UniValue dumpwallet(const JSONRPCRequest& request)
|
||||||
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");
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream file;
|
fsbridge::ofstream file;
|
||||||
file.open(filepath.string().c_str());
|
file.open(filepath);
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue