mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-01-31 10:30:52 +00:00
rewire calls to boost::filesystem to use the fs wrapper
* replaces boost/filesystem includes with fs.h * replaces boost::filesystem:: with fs:: * removes file-local fs namespace aliases * removes unused includes from: * net.h * src/wallet/walletdb.cpp * adds missing includes in: * rpc/protocol.cpp * test/dbwrapper_tests.cpp * wallet/rpcutil.cpp
This commit is contained in:
parent
e044c640b3
commit
a2caaf1f99
@ -8,14 +8,13 @@
|
||||
#include "addrman.h"
|
||||
#include "chainparams.h"
|
||||
#include "clientversion.h"
|
||||
#include "fs.h"
|
||||
#include "hash.h"
|
||||
#include "random.h"
|
||||
#include "streams.h"
|
||||
#include "tinyformat.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
CBanDB::CBanDB()
|
||||
{
|
||||
pathBanlist = GetDataDir() / "banlist.dat";
|
||||
@ -36,7 +35,7 @@ bool CBanDB::Write(const banmap_t& banSet)
|
||||
ssBanlist << hash;
|
||||
|
||||
// open temp output file, and associate with CAutoFile
|
||||
boost::filesystem::path pathTmp = GetDataDir() / tmpfn;
|
||||
fs::path pathTmp = GetDataDir() / tmpfn;
|
||||
FILE *file = fopen(pathTmp.string().c_str(), "wb");
|
||||
CAutoFile fileout(file, SER_DISK, CLIENT_VERSION);
|
||||
if (fileout.IsNull())
|
||||
@ -68,7 +67,7 @@ bool CBanDB::Read(banmap_t& banSet)
|
||||
return error("%s: Failed to open file %s", __func__, pathBanlist.string());
|
||||
|
||||
// use file size to size memory buffer
|
||||
uint64_t fileSize = boost::filesystem::file_size(pathBanlist);
|
||||
uint64_t fileSize = fs::file_size(pathBanlist);
|
||||
uint64_t dataSize = 0;
|
||||
// Don't try to resize to a negative number if file is small
|
||||
if (fileSize >= sizeof(uint256))
|
||||
@ -133,7 +132,7 @@ bool CAddrDB::Write(const CAddrMan& addr)
|
||||
ssPeers << hash;
|
||||
|
||||
// open temp output file, and associate with CAutoFile
|
||||
boost::filesystem::path pathTmp = GetDataDir() / tmpfn;
|
||||
fs::path pathTmp = GetDataDir() / tmpfn;
|
||||
FILE *file = fopen(pathTmp.string().c_str(), "wb");
|
||||
CAutoFile fileout(file, SER_DISK, CLIENT_VERSION);
|
||||
if (fileout.IsNull())
|
||||
@ -165,7 +164,7 @@ bool CAddrDB::Read(CAddrMan& addr)
|
||||
return error("%s: Failed to open file %s", __func__, pathAddr.string());
|
||||
|
||||
// use file size to size memory buffer
|
||||
uint64_t fileSize = boost::filesystem::file_size(pathAddr);
|
||||
uint64_t fileSize = fs::file_size(pathAddr);
|
||||
uint64_t dataSize = 0;
|
||||
// Don't try to resize to a negative number if file is small
|
||||
if (fileSize >= sizeof(uint256))
|
||||
|
||||
@ -6,11 +6,11 @@
|
||||
#ifndef BITCOIN_ADDRDB_H
|
||||
#define BITCOIN_ADDRDB_H
|
||||
|
||||
#include "fs.h"
|
||||
#include "serialize.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
class CSubNet;
|
||||
class CAddrMan;
|
||||
@ -80,7 +80,7 @@ typedef std::map<CSubNet, CBanEntry> banmap_t;
|
||||
class CAddrDB
|
||||
{
|
||||
private:
|
||||
boost::filesystem::path pathAddr;
|
||||
fs::path pathAddr;
|
||||
public:
|
||||
CAddrDB();
|
||||
bool Write(const CAddrMan& addr);
|
||||
@ -92,7 +92,7 @@ public:
|
||||
class CBanDB
|
||||
{
|
||||
private:
|
||||
boost::filesystem::path pathBanlist;
|
||||
fs::path pathBanlist;
|
||||
public:
|
||||
CBanDB();
|
||||
bool Write(const banmap_t& banSet);
|
||||
|
||||
@ -11,12 +11,12 @@
|
||||
#include "chainparamsbase.h"
|
||||
#include "clientversion.h"
|
||||
#include "compat.h"
|
||||
#include "fs.h"
|
||||
#include "rpc/client.h"
|
||||
#include "rpc/protocol.h"
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <event2/buffer.h>
|
||||
@ -99,7 +99,7 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (!boost::filesystem::is_directory(GetDataDir(false))) {
|
||||
if (!fs::is_directory(GetDataDir(false))) {
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "chainparams.h"
|
||||
#include "clientversion.h"
|
||||
#include "compat.h"
|
||||
#include "fs.h"
|
||||
#include "rpc/server.h"
|
||||
#include "init.h"
|
||||
#include "noui.h"
|
||||
@ -21,7 +22,6 @@
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include <stdio.h>
|
||||
@ -98,7 +98,7 @@ bool AppInit(int argc, char* argv[])
|
||||
|
||||
try
|
||||
{
|
||||
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
||||
if (!fs::is_directory(GetDataDir(false)))
|
||||
{
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str());
|
||||
return false;
|
||||
|
||||
@ -4,11 +4,10 @@
|
||||
|
||||
#include "dbwrapper.h"
|
||||
|
||||
#include "fs.h"
|
||||
#include "util.h"
|
||||
#include "random.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <leveldb/cache.h>
|
||||
#include <leveldb/env.h>
|
||||
#include <leveldb/filter_policy.h>
|
||||
@ -31,7 +30,7 @@ static leveldb::Options GetOptions(size_t nCacheSize)
|
||||
return options;
|
||||
}
|
||||
|
||||
CDBWrapper::CDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory, bool fWipe, bool obfuscate)
|
||||
CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bool fWipe, bool obfuscate)
|
||||
{
|
||||
penv = NULL;
|
||||
readoptions.verify_checksums = true;
|
||||
|
||||
@ -6,14 +6,13 @@
|
||||
#define BITCOIN_DBWRAPPER_H
|
||||
|
||||
#include "clientversion.h"
|
||||
#include "fs.h"
|
||||
#include "serialize.h"
|
||||
#include "streams.h"
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <leveldb/db.h>
|
||||
#include <leveldb/write_batch.h>
|
||||
|
||||
@ -199,7 +198,7 @@ public:
|
||||
* @param[in] obfuscate If true, store data obfuscated via simple XOR. If false, XOR
|
||||
* with a zero'd byte array.
|
||||
*/
|
||||
CDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false, bool obfuscate = false);
|
||||
CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false, bool obfuscate = false);
|
||||
~CDBWrapper();
|
||||
|
||||
template <typename K, typename V>
|
||||
|
||||
50
src/init.cpp
50
src/init.cpp
@ -18,6 +18,7 @@
|
||||
#include "compat/sanity.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "crypto/scrypt.h" // for scrypt_detect_sse2
|
||||
#include "fs.h"
|
||||
#include "httpserver.h"
|
||||
#include "httprpc.h"
|
||||
#include "key.h"
|
||||
@ -57,7 +58,6 @@
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/interprocess/sync/file_lock.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@ -219,7 +219,7 @@ void Shutdown()
|
||||
|
||||
if (fFeeEstimatesInitialized)
|
||||
{
|
||||
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
|
||||
fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
|
||||
CAutoFile est_fileout(fopen(est_path.string().c_str(), "wb"), SER_DISK, CLIENT_VERSION);
|
||||
if (!est_fileout.IsNull())
|
||||
mempool.WriteFeeEstimates(est_fileout);
|
||||
@ -257,8 +257,8 @@ void Shutdown()
|
||||
|
||||
#ifndef WIN32
|
||||
try {
|
||||
boost::filesystem::remove(GetPidFile());
|
||||
} catch (const boost::filesystem::filesystem_error& e) {
|
||||
fs::remove(GetPidFile());
|
||||
} catch (const fs::filesystem_error& e) {
|
||||
LogPrintf("%s: Unable to remove pidfile: %s\n", __func__, e.what());
|
||||
}
|
||||
#endif
|
||||
@ -583,14 +583,14 @@ struct CImportingNow
|
||||
// works correctly.
|
||||
void CleanupBlockRevFiles()
|
||||
{
|
||||
std::map<std::string, boost::filesystem::path> mapBlockFiles;
|
||||
std::map<std::string, fs::path> mapBlockFiles;
|
||||
|
||||
// Glob all blk?????.dat and rev?????.dat files from the blocks directory.
|
||||
// Remove the rev files immediately and insert the blk file paths into an
|
||||
// ordered map keyed by block file index.
|
||||
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
|
||||
boost::filesystem::path blocksdir = GetDataDir() / "blocks";
|
||||
for (boost::filesystem::directory_iterator it(blocksdir); it != boost::filesystem::directory_iterator(); it++) {
|
||||
fs::path blocksdir = GetDataDir() / "blocks";
|
||||
for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) {
|
||||
if (is_regular_file(*it) &&
|
||||
it->path().filename().string().length() == 12 &&
|
||||
it->path().filename().string().substr(8,4) == ".dat")
|
||||
@ -607,7 +607,7 @@ void CleanupBlockRevFiles()
|
||||
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
|
||||
// start removing block files.
|
||||
int nContigCounter = 0;
|
||||
BOOST_FOREACH(const PAIRTYPE(std::string, boost::filesystem::path)& item, mapBlockFiles) {
|
||||
BOOST_FOREACH(const PAIRTYPE(std::string, fs::path)& item, mapBlockFiles) {
|
||||
if (atoi(item.first) == nContigCounter) {
|
||||
nContigCounter++;
|
||||
continue;
|
||||
@ -616,7 +616,7 @@ void CleanupBlockRevFiles()
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
void ThreadImport(std::vector<fs::path> vImportFiles)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
RenameThread("dogecoin-loadblk");
|
||||
@ -629,7 +629,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
int nFile = 0;
|
||||
while (true) {
|
||||
CDiskBlockPos pos(nFile, 0);
|
||||
if (!boost::filesystem::exists(GetBlockPosFilename(pos, "blk")))
|
||||
if (!fs::exists(GetBlockPosFilename(pos, "blk")))
|
||||
break; // No block files left to reindex
|
||||
FILE *file = OpenBlockFile(pos, true);
|
||||
if (!file)
|
||||
@ -646,11 +646,11 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
}
|
||||
|
||||
// hardcoded $DATADIR/bootstrap.dat
|
||||
boost::filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
|
||||
if (boost::filesystem::exists(pathBootstrap)) {
|
||||
fs::path pathBootstrap = GetDataDir() / "bootstrap.dat";
|
||||
if (fs::exists(pathBootstrap)) {
|
||||
FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
|
||||
if (file) {
|
||||
boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
|
||||
fs::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
|
||||
LogPrintf("Importing bootstrap.dat...\n");
|
||||
LoadExternalBlockFile(chainparams, file);
|
||||
RenameOver(pathBootstrap, pathBootstrapOld);
|
||||
@ -660,7 +660,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
}
|
||||
|
||||
// -loadblock=
|
||||
BOOST_FOREACH(const boost::filesystem::path& path, vImportFiles) {
|
||||
BOOST_FOREACH(const fs::path& path, vImportFiles) {
|
||||
FILE *file = fopen(path.string().c_str(), "rb");
|
||||
if (file) {
|
||||
LogPrintf("Importing blocks file %s...\n", path.string());
|
||||
@ -1159,7 +1159,7 @@ static bool LockDataDirectory(bool probeOnly)
|
||||
std::string strDataDir = GetDataDir().string();
|
||||
|
||||
// Make sure only a single Bitcoin process is using the data directory.
|
||||
boost::filesystem::path pathLockFile = GetDataDir() / ".lock";
|
||||
fs::path pathLockFile = GetDataDir() / ".lock";
|
||||
FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
|
||||
if (file) fclose(file);
|
||||
|
||||
@ -1425,20 +1425,20 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
bool fReindexChainState = GetBoolArg("-reindex-chainstate", false);
|
||||
|
||||
// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
|
||||
boost::filesystem::path blocksDir = GetDataDir() / "blocks";
|
||||
if (!boost::filesystem::exists(blocksDir))
|
||||
fs::path blocksDir = GetDataDir() / "blocks";
|
||||
if (!fs::exists(blocksDir))
|
||||
{
|
||||
boost::filesystem::create_directories(blocksDir);
|
||||
fs::create_directories(blocksDir);
|
||||
bool linked = false;
|
||||
for (unsigned int i = 1; i < 10000; i++) {
|
||||
boost::filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
|
||||
if (!boost::filesystem::exists(source)) break;
|
||||
boost::filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
|
||||
fs::path source = GetDataDir() / strprintf("blk%04u.dat", i);
|
||||
if (!fs::exists(source)) break;
|
||||
fs::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
|
||||
try {
|
||||
boost::filesystem::create_hard_link(source, dest);
|
||||
fs::create_hard_link(source, dest);
|
||||
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
|
||||
linked = true;
|
||||
} catch (const boost::filesystem::filesystem_error& e) {
|
||||
} catch (const fs::filesystem_error& e) {
|
||||
// Note: hardlink creation failing is not a disaster, it just means
|
||||
// blocks will get re-downloaded from peers.
|
||||
LogPrintf("Error hardlinking blk%04u.dat: %s\n", i, e.what());
|
||||
@ -1595,7 +1595,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart);
|
||||
|
||||
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
|
||||
fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
|
||||
CAutoFile est_filein(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION);
|
||||
// Allowed to fail as this file IS missing on first startup.
|
||||
if (!est_filein.IsNull())
|
||||
@ -1651,7 +1651,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (IsArgSet("-blocknotify"))
|
||||
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
||||
|
||||
std::vector<boost::filesystem::path> vImportFiles;
|
||||
std::vector<fs::path> vImportFiles;
|
||||
if (mapMultiArgs.count("-loadblock"))
|
||||
{
|
||||
BOOST_FOREACH(const std::string& strFile, mapMultiArgs.at("-loadblock"))
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include "chainparams.h"
|
||||
#include "clientmodel.h"
|
||||
#include "compat.h"
|
||||
#include "fs.h"
|
||||
#include "guiconstants.h"
|
||||
#include "guiutil.h"
|
||||
#include "intro.h"
|
||||
@ -40,7 +41,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
@ -589,7 +589,7 @@ MAIN_FUNCTION
|
||||
|
||||
/// 6. Determine availability of data directory and parse bitcoin.conf
|
||||
/// - Do not call GetDataDir(true) before this step finishes
|
||||
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
||||
if (!fs::is_directory(GetDataDir(false)))
|
||||
{
|
||||
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
|
||||
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(GetArg("-datadir", ""))));
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "bitcoinaddressvalidator.h"
|
||||
#include "bitcoinunits.h"
|
||||
#include "fs.h"
|
||||
#include "qvalidatedlineedit.h"
|
||||
#include "walletmodel.h"
|
||||
|
||||
@ -40,11 +41,6 @@
|
||||
#include "shlwapi.h"
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#if BOOST_FILESYSTEM_VERSION >= 3
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
#endif
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
#include <QAbstractItemView>
|
||||
@ -69,7 +65,7 @@
|
||||
#endif
|
||||
|
||||
#if BOOST_FILESYSTEM_VERSION >= 3
|
||||
static boost::filesystem::detail::utf8_codecvt_facet utf8;
|
||||
static fs::detail::utf8_codecvt_facet utf8;
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
@ -413,10 +409,10 @@ void bringToFront(QWidget* w)
|
||||
|
||||
void openDebugLogfile()
|
||||
{
|
||||
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
|
||||
fs::path pathDebug = GetDataDir() / "debug.log";
|
||||
|
||||
/* Open debug.log with the associated application */
|
||||
if (boost::filesystem::exists(pathDebug))
|
||||
if (fs::exists(pathDebug))
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathDebug)));
|
||||
}
|
||||
|
||||
@ -596,7 +592,7 @@ TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* t
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
boost::filesystem::path static StartupShortcutPath()
|
||||
fs::path static StartupShortcutPath()
|
||||
{
|
||||
std::string chain = ChainNameFromCommandLine();
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
@ -609,13 +605,13 @@ boost::filesystem::path static StartupShortcutPath()
|
||||
bool GetStartOnSystemStartup()
|
||||
{
|
||||
// check for Bitcoin*.lnk
|
||||
return boost::filesystem::exists(StartupShortcutPath());
|
||||
return fs::exists(StartupShortcutPath());
|
||||
}
|
||||
|
||||
bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
{
|
||||
// If the shortcut exists already, remove it for updating
|
||||
boost::filesystem::remove(StartupShortcutPath());
|
||||
fs::remove(StartupShortcutPath());
|
||||
|
||||
if (fAutoStart)
|
||||
{
|
||||
@ -685,10 +681,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
// Follow the Desktop Application Autostart Spec:
|
||||
// http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html
|
||||
|
||||
boost::filesystem::path static GetAutostartDir()
|
||||
fs::path static GetAutostartDir()
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
char* pszConfigHome = getenv("XDG_CONFIG_HOME");
|
||||
if (pszConfigHome) return fs::path(pszConfigHome) / "autostart";
|
||||
char* pszHome = getenv("HOME");
|
||||
@ -696,7 +690,7 @@ boost::filesystem::path static GetAutostartDir()
|
||||
return fs::path();
|
||||
}
|
||||
|
||||
boost::filesystem::path static GetAutostartFilePath()
|
||||
fs::path static GetAutostartFilePath()
|
||||
{
|
||||
std::string chain = ChainNameFromCommandLine();
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
@ -706,7 +700,7 @@ boost::filesystem::path static GetAutostartFilePath()
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
{
|
||||
boost::filesystem::ifstream optionFile(GetAutostartFilePath());
|
||||
fs::ifstream optionFile(GetAutostartFilePath());
|
||||
if (!optionFile.good())
|
||||
return false;
|
||||
// Scan through file for "Hidden=true":
|
||||
@ -726,7 +720,7 @@ bool GetStartOnSystemStartup()
|
||||
bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
{
|
||||
if (!fAutoStart)
|
||||
boost::filesystem::remove(GetAutostartFilePath());
|
||||
fs::remove(GetAutostartFilePath());
|
||||
else
|
||||
{
|
||||
char pszExePath[MAX_PATH+1];
|
||||
@ -734,9 +728,9 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1) == -1)
|
||||
return false;
|
||||
|
||||
boost::filesystem::create_directories(GetAutostartDir());
|
||||
fs::create_directories(GetAutostartDir());
|
||||
|
||||
boost::filesystem::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out|std::ios_base::trunc);
|
||||
fs::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out|std::ios_base::trunc);
|
||||
if (!optionFile.good())
|
||||
return false;
|
||||
std::string chain = ChainNameFromCommandLine();
|
||||
@ -859,23 +853,23 @@ void setClipboard(const QString& str)
|
||||
}
|
||||
|
||||
#if BOOST_FILESYSTEM_VERSION >= 3
|
||||
boost::filesystem::path qstringToBoostPath(const QString &path)
|
||||
fs::path qstringToBoostPath(const QString &path)
|
||||
{
|
||||
return boost::filesystem::path(path.toStdString(), utf8);
|
||||
return fs::path(path.toStdString(), utf8);
|
||||
}
|
||||
|
||||
QString boostPathToQString(const boost::filesystem::path &path)
|
||||
QString boostPathToQString(const fs::path &path)
|
||||
{
|
||||
return QString::fromStdString(path.string(utf8));
|
||||
}
|
||||
#else
|
||||
#warning Conversion between boost path and QString can use invalid character encoding with boost_filesystem v2 and older
|
||||
boost::filesystem::path qstringToBoostPath(const QString &path)
|
||||
fs::path qstringToBoostPath(const QString &path)
|
||||
{
|
||||
return boost::filesystem::path(path.toStdString());
|
||||
return fs::path(path.toStdString());
|
||||
}
|
||||
|
||||
QString boostPathToQString(const boost::filesystem::path &path)
|
||||
QString boostPathToQString(const fs::path &path)
|
||||
{
|
||||
return QString::fromStdString(path.string());
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#define BITCOIN_QT_GUIUTIL_H
|
||||
|
||||
#include "amount.h"
|
||||
#include "fs.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QHeaderView>
|
||||
@ -17,8 +18,6 @@
|
||||
#include <QTableView>
|
||||
#include <QLabel>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
class QValidatedLineEdit;
|
||||
class SendCoinsRecipient;
|
||||
|
||||
@ -187,10 +186,10 @@ namespace GUIUtil
|
||||
void restoreWindowGeometry(const QString& strSetting, const QSize &defaultSizeIn, QWidget *parent);
|
||||
|
||||
/* Convert QString to OS specific boost path through UTF-8 */
|
||||
boost::filesystem::path qstringToBoostPath(const QString &path);
|
||||
fs::path qstringToBoostPath(const QString &path);
|
||||
|
||||
/* Convert OS specific boost path to QString through UTF-8 */
|
||||
QString boostPathToQString(const boost::filesystem::path &path);
|
||||
QString boostPathToQString(const fs::path &path);
|
||||
|
||||
/* Convert seconds into a QString with days, hours, mins, secs */
|
||||
QString formatDurationStr(int secs);
|
||||
|
||||
@ -10,12 +10,11 @@
|
||||
#include "intro.h"
|
||||
#include "ui_intro.h"
|
||||
|
||||
#include "fs.h"
|
||||
#include "guiutil.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
@ -71,7 +70,6 @@ FreespaceChecker::FreespaceChecker(Intro *_intro)
|
||||
|
||||
void FreespaceChecker::check()
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
QString dataDirStr = intro->getPathToCheck();
|
||||
fs::path dataDir = GUIUtil::qstringToBoostPath(dataDirStr);
|
||||
uint64_t freeBytesAvailable = 0;
|
||||
@ -173,7 +171,6 @@ QString Intro::getDefaultDataDirectory()
|
||||
|
||||
bool Intro::pickDataDirectory()
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
QSettings settings;
|
||||
/* If data directory provided on command line, no need to look at settings
|
||||
or show a picking dialog */
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "fs.h"
|
||||
#include "validation.h"
|
||||
#include "rpc/register.h"
|
||||
#include "rpc/server.h"
|
||||
@ -18,8 +19,6 @@
|
||||
#include <QDir>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
static UniValue rpcNestedTest_rpc(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp) {
|
||||
@ -153,5 +152,5 @@ void RPCNestedTests::rpcNestedTests()
|
||||
delete pcoinsdbview;
|
||||
delete pblocktree;
|
||||
|
||||
boost::filesystem::remove_all(boost::filesystem::path(path));
|
||||
fs::remove_all(fs::path(path));
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include "rpc/protocol.h"
|
||||
|
||||
#include "fs.h"
|
||||
#include "random.h"
|
||||
#include "tinyformat.h"
|
||||
#include "util.h"
|
||||
@ -69,9 +70,9 @@ static const std::string COOKIEAUTH_USER = "__cookie__";
|
||||
/** Default name for auth cookie file */
|
||||
static const std::string COOKIEAUTH_FILE = ".cookie";
|
||||
|
||||
boost::filesystem::path GetAuthCookieFile()
|
||||
fs::path GetAuthCookieFile()
|
||||
{
|
||||
boost::filesystem::path path(GetArg("-rpccookiefile", COOKIEAUTH_FILE));
|
||||
fs::path path(GetArg("-rpccookiefile", COOKIEAUTH_FILE));
|
||||
if (!path.is_complete()) path = GetDataDir() / path;
|
||||
return path;
|
||||
}
|
||||
@ -87,7 +88,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
|
||||
* these are set to 077 in init.cpp unless overridden with -sysperms.
|
||||
*/
|
||||
std::ofstream file;
|
||||
boost::filesystem::path filepath = GetAuthCookieFile();
|
||||
fs::path filepath = GetAuthCookieFile();
|
||||
file.open(filepath.string().c_str());
|
||||
if (!file.is_open()) {
|
||||
LogPrintf("Unable to open cookie authentication file %s for writing\n", filepath.string());
|
||||
@ -106,7 +107,7 @@ bool GetAuthCookie(std::string *cookie_out)
|
||||
{
|
||||
std::ifstream file;
|
||||
std::string cookie;
|
||||
boost::filesystem::path filepath = GetAuthCookieFile();
|
||||
fs::path filepath = GetAuthCookieFile();
|
||||
file.open(filepath.string().c_str());
|
||||
if (!file.is_open())
|
||||
return false;
|
||||
@ -121,8 +122,8 @@ bool GetAuthCookie(std::string *cookie_out)
|
||||
void DeleteAuthCookie()
|
||||
{
|
||||
try {
|
||||
boost::filesystem::remove(GetAuthCookieFile());
|
||||
} catch (const boost::filesystem::filesystem_error& e) {
|
||||
fs::remove(GetAuthCookieFile());
|
||||
} catch (const fs::filesystem_error& e) {
|
||||
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
#ifndef BITCOIN_RPCPROTOCOL_H
|
||||
#define BITCOIN_RPCPROTOCOL_H
|
||||
|
||||
#include "fs.h"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
@ -85,7 +86,7 @@ std::string JSONRPCReply(const UniValue& result, const UniValue& error, const Un
|
||||
UniValue JSONRPCError(int code, const std::string& message);
|
||||
|
||||
/** Get name of RPC authentication cookie file */
|
||||
boost::filesystem::path GetAuthCookieFile();
|
||||
fs::path GetAuthCookieFile();
|
||||
/** Generate a new RPC authentication cookie and write it to disk */
|
||||
bool GenerateAuthCookie(std::string *cookie_out);
|
||||
/** Read the RPC authentication cookie from disk */
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "rpc/server.h"
|
||||
|
||||
#include "base58.h"
|
||||
#include "fs.h"
|
||||
#include "init.h"
|
||||
#include "random.h"
|
||||
#include "sync.h"
|
||||
@ -17,7 +18,6 @@
|
||||
#include <univalue.h>
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "dbwrapper.h"
|
||||
#include "fs.h"
|
||||
#include "uint256.h"
|
||||
#include "random.h"
|
||||
#include "test/test_bitcoin.h"
|
||||
@ -29,7 +30,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (int i = 0; i < 2; i++) {
|
||||
bool obfuscate = (bool)i;
|
||||
boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path();
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
char key = 'k';
|
||||
uint256 in = GetRandHash();
|
||||
@ -50,7 +51,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch)
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (int i = 0; i < 2; i++) {
|
||||
bool obfuscate = (bool)i;
|
||||
boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path();
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
char key = 'i';
|
||||
@ -87,7 +88,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (int i = 0; i < 2; i++) {
|
||||
bool obfuscate = (bool)i;
|
||||
boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path();
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
// The two keys are intentionally chosen for ordering
|
||||
@ -126,8 +127,8 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
// Test that we do not obfuscation if there is existing data.
|
||||
BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
||||
{
|
||||
// We're going to share this boost::filesystem::path between two wrappers
|
||||
boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
|
||||
// We're going to share this fs::path between two wrappers
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path();
|
||||
create_directories(ph);
|
||||
|
||||
// Set up a non-obfuscated wrapper to write some initial data.
|
||||
@ -167,8 +168,8 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
||||
// Ensure that we start obfuscating during a reindex.
|
||||
BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
||||
{
|
||||
// We're going to share this boost::filesystem::path between two wrappers
|
||||
boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
|
||||
// We're going to share this fs::path between two wrappers
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path();
|
||||
create_directories(ph);
|
||||
|
||||
// Set up a non-obfuscated wrapper to write some initial data.
|
||||
@ -203,7 +204,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(iterator_ordering)
|
||||
{
|
||||
boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path();
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, false);
|
||||
for (int x=0x00; x<256; ++x) {
|
||||
uint8_t key = x;
|
||||
@ -274,7 +275,7 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
|
||||
{
|
||||
char buf[10];
|
||||
|
||||
boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
|
||||
fs::path ph = fs::temp_directory_path() / fs::unique_path();
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, false);
|
||||
for (uint32_t x=0x00; x<10; ++x) {
|
||||
for (uint32_t y = 0; y < 10; y++) {
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "chainparams.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "fs.h"
|
||||
#include "key.h"
|
||||
#include "validation.h"
|
||||
#include "miner.h"
|
||||
@ -27,7 +28,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
@ -67,7 +67,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
ClearDatadirCache();
|
||||
pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
|
||||
boost::filesystem::create_directories(pathTemp);
|
||||
fs::create_directories(pathTemp);
|
||||
ForceSetArg("-datadir", pathTemp.string());
|
||||
mempool.setSanityCheck(1.0);
|
||||
pblocktree = new CBlockTreeDB(1 << 20, true);
|
||||
@ -96,7 +96,7 @@ TestingSetup::~TestingSetup()
|
||||
delete pcoinsTip;
|
||||
delete pcoinsdbview;
|
||||
delete pblocktree;
|
||||
boost::filesystem::remove_all(pathTemp);
|
||||
fs::remove_all(pathTemp);
|
||||
}
|
||||
|
||||
TestChain240Setup::TestChain240Setup() : TestingSetup(CBaseChainParams::REGTEST)
|
||||
|
||||
@ -6,12 +6,12 @@
|
||||
#define BITCOIN_TEST_TEST_BITCOIN_H
|
||||
|
||||
#include "chainparamsbase.h"
|
||||
#include "fs.h"
|
||||
#include "key.h"
|
||||
#include "pubkey.h"
|
||||
#include "txdb.h"
|
||||
#include "txmempool.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
/** Basic testing setup.
|
||||
@ -30,7 +30,7 @@ struct BasicTestingSetup {
|
||||
class CConnman;
|
||||
struct TestingSetup: public BasicTestingSetup {
|
||||
CCoinsViewDB *pcoinsdbview;
|
||||
boost::filesystem::path pathTemp;
|
||||
fs::path pathTemp;
|
||||
boost::thread_group threadGroup;
|
||||
CConnman* connman;
|
||||
|
||||
|
||||
@ -4,29 +4,29 @@
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
#include "fs.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
boost::filesystem::path GetTempPath() {
|
||||
fs::path GetTempPath() {
|
||||
#if BOOST_FILESYSTEM_VERSION == 3
|
||||
return boost::filesystem::temp_directory_path();
|
||||
return fs::temp_directory_path();
|
||||
#else
|
||||
// TODO: remove when we don't support filesystem v2 anymore
|
||||
boost::filesystem::path path;
|
||||
fs::path path;
|
||||
#ifdef WIN32
|
||||
char pszPath[MAX_PATH] = "";
|
||||
|
||||
if (GetTempPathA(MAX_PATH, pszPath))
|
||||
path = boost::filesystem::path(pszPath);
|
||||
path = fs::path(pszPath);
|
||||
#else
|
||||
path = boost::filesystem::path("/tmp");
|
||||
path = fs::path("/tmp");
|
||||
#endif
|
||||
if (path.empty() || !boost::filesystem::is_directory(path)) {
|
||||
if (path.empty() || !fs::is_directory(path)) {
|
||||
LogPrintf("GetTempPath(): failed to find temp path\n");
|
||||
return boost::filesystem::path("");
|
||||
return fs::path("");
|
||||
}
|
||||
return path;
|
||||
#endif
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
#ifndef BITCOIN_TEST_TESTUTIL_H
|
||||
#define BITCOIN_TEST_TESTUTIL_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include "fs.h"
|
||||
|
||||
boost::filesystem::path GetTempPath();
|
||||
fs::path GetTempPath();
|
||||
|
||||
#endif // BITCOIN_TEST_TESTUTIL_H
|
||||
|
||||
63
src/util.cpp
63
src/util.cpp
@ -11,6 +11,7 @@
|
||||
#include "util.h"
|
||||
|
||||
#include "chainparamsbase.h"
|
||||
#include "fs.h"
|
||||
#include "random.h"
|
||||
#include "serialize.h"
|
||||
#include "sync.h"
|
||||
@ -80,8 +81,6 @@
|
||||
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/program_options/detail/config_file.hpp>
|
||||
#include <boost/program_options/parsers.hpp>
|
||||
@ -217,7 +216,7 @@ void OpenDebugLog()
|
||||
|
||||
assert(fileout == NULL);
|
||||
assert(vMsgsBeforeOpenLog);
|
||||
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
|
||||
fs::path pathDebug = GetDataDir() / "debug.log";
|
||||
fileout = fopen(pathDebug.string().c_str(), "a");
|
||||
if (fileout) {
|
||||
setbuf(fileout, NULL); // unbuffered
|
||||
@ -322,7 +321,7 @@ int LogPrintStr(const std::string &str)
|
||||
// reopen the log file, if requested
|
||||
if (fReopenDebugLog) {
|
||||
fReopenDebugLog = false;
|
||||
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
|
||||
fs::path pathDebug = GetDataDir() / "debug.log";
|
||||
if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL)
|
||||
setbuf(fileout, NULL); // unbuffered
|
||||
}
|
||||
@ -480,9 +479,8 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
|
||||
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
|
||||
}
|
||||
|
||||
boost::filesystem::path GetDefaultDataDir()
|
||||
fs::path GetDefaultDataDir()
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Bitcoin
|
||||
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Bitcoin
|
||||
// Mac: ~/Library/Application Support/Bitcoin
|
||||
@ -507,14 +505,12 @@ boost::filesystem::path GetDefaultDataDir()
|
||||
#endif
|
||||
}
|
||||
|
||||
static boost::filesystem::path pathCached;
|
||||
static boost::filesystem::path pathCachedNetSpecific;
|
||||
static fs::path pathCached;
|
||||
static fs::path pathCachedNetSpecific;
|
||||
static CCriticalSection csPathCached;
|
||||
|
||||
const boost::filesystem::path &GetDataDir(bool fNetSpecific)
|
||||
const fs::path &GetDataDir(bool fNetSpecific)
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
LOCK(csPathCached);
|
||||
|
||||
fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached;
|
||||
@ -545,16 +541,15 @@ void ClearDatadirCache()
|
||||
{
|
||||
LOCK(csPathCached);
|
||||
|
||||
pathCached = boost::filesystem::path();
|
||||
pathCachedNetSpecific = boost::filesystem::path();
|
||||
pathCached = fs::path();
|
||||
pathCachedNetSpecific = fs::path();
|
||||
}
|
||||
|
||||
static boost::filesystem::path backupPathCached;
|
||||
static fs::path backupPathCached;
|
||||
static CCriticalSection csBackupPathCached;
|
||||
|
||||
const boost::filesystem::path &GetBackupDir()
|
||||
const fs::path &GetBackupDir()
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
LOCK(csBackupPathCached);
|
||||
|
||||
fs::path &path = backupPathCached;
|
||||
@ -587,9 +582,9 @@ const boost::filesystem::path &GetBackupDir()
|
||||
return path;
|
||||
}
|
||||
|
||||
boost::filesystem::path GetConfigFile(const std::string& confPath)
|
||||
fs::path GetConfigFile(const std::string& confPath)
|
||||
{
|
||||
boost::filesystem::path pathConfigFile(confPath);
|
||||
fs::path pathConfigFile(confPath);
|
||||
if (!pathConfigFile.is_complete())
|
||||
pathConfigFile = GetDataDir(false) / pathConfigFile;
|
||||
|
||||
@ -598,7 +593,7 @@ boost::filesystem::path GetConfigFile(const std::string& confPath)
|
||||
|
||||
void ReadConfigFile(const std::string& confPath)
|
||||
{
|
||||
boost::filesystem::ifstream streamConfig(GetConfigFile(confPath));
|
||||
fs::ifstream streamConfig(GetConfigFile(confPath));
|
||||
if (!streamConfig.good())
|
||||
return; // No bitcoin.conf file is OK
|
||||
|
||||
@ -623,14 +618,14 @@ void ReadConfigFile(const std::string& confPath)
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
boost::filesystem::path GetPidFile()
|
||||
fs::path GetPidFile()
|
||||
{
|
||||
boost::filesystem::path pathPidFile(GetArg("-pid", BITCOIN_PID_FILENAME));
|
||||
fs::path pathPidFile(GetArg("-pid", BITCOIN_PID_FILENAME));
|
||||
if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile;
|
||||
return pathPidFile;
|
||||
}
|
||||
|
||||
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
|
||||
void CreatePidFile(const fs::path &path, pid_t pid)
|
||||
{
|
||||
FILE* file = fopen(path.string().c_str(), "w");
|
||||
if (file)
|
||||
@ -641,7 +636,7 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
|
||||
}
|
||||
#endif
|
||||
|
||||
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
|
||||
bool RenameOver(fs::path src, fs::path dest)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
|
||||
@ -657,13 +652,13 @@ bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
|
||||
* Specifically handles case where path p exists, but it wasn't possible for the user to
|
||||
* write to the parent directory.
|
||||
*/
|
||||
bool TryCreateDirectory(const boost::filesystem::path& p)
|
||||
bool TryCreateDirectory(const fs::path& p)
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::filesystem::create_directory(p);
|
||||
} catch (const boost::filesystem::filesystem_error&) {
|
||||
if (!boost::filesystem::exists(p) || !boost::filesystem::is_directory(p))
|
||||
return fs::create_directory(p);
|
||||
} catch (const fs::filesystem_error&) {
|
||||
if (!fs::exists(p) || !fs::is_directory(p))
|
||||
throw;
|
||||
}
|
||||
|
||||
@ -770,11 +765,11 @@ void ShrinkDebugFile()
|
||||
// Amount of debug.log to save at end when shrinking (must fit in memory)
|
||||
constexpr size_t RECENT_DEBUG_HISTORY_SIZE = 10 * 1000000;
|
||||
// Scroll debug.log if it's getting too big
|
||||
boost::filesystem::path pathLog = GetDataDir() / "debug.log";
|
||||
fs::path pathLog = GetDataDir() / "debug.log";
|
||||
FILE* file = fopen(pathLog.string().c_str(), "r");
|
||||
// If debug.log file is more than 10% bigger the RECENT_DEBUG_HISTORY_SIZE
|
||||
// trim it down by saving only the last RECENT_DEBUG_HISTORY_SIZE bytes
|
||||
if (file && boost::filesystem::file_size(pathLog) > 11 * (RECENT_DEBUG_HISTORY_SIZE / 10))
|
||||
if (file && fs::file_size(pathLog) > 11 * (RECENT_DEBUG_HISTORY_SIZE / 10))
|
||||
{
|
||||
// Restart the file with some of the end
|
||||
std::vector<char> vch(RECENT_DEBUG_HISTORY_SIZE, 0);
|
||||
@ -794,10 +789,8 @@ void ShrinkDebugFile()
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
|
||||
fs::path GetSpecialFolderPath(int nFolder, bool fCreate)
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
char pszPath[MAX_PATH] = "";
|
||||
|
||||
if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate))
|
||||
@ -857,9 +850,9 @@ void SetupEnvironment()
|
||||
// The path locale is lazy initialized and to avoid deinitialization errors
|
||||
// in multithreading environments, it is set explicitly by the main thread.
|
||||
// A dummy locale is used to extract the internal default locale, used by
|
||||
// boost::filesystem::path, which is then used to explicitly imbue the path.
|
||||
std::locale loc = boost::filesystem::path::imbue(std::locale::classic());
|
||||
boost::filesystem::path::imbue(loc);
|
||||
// fs::path, which is then used to explicitly imbue the path.
|
||||
std::locale loc = fs::path::imbue(std::locale::classic());
|
||||
fs::path::imbue(loc);
|
||||
}
|
||||
|
||||
bool SetupNetworking()
|
||||
|
||||
20
src/util.h
20
src/util.h
@ -16,6 +16,7 @@
|
||||
#endif
|
||||
|
||||
#include "compat.h"
|
||||
#include "fs.h"
|
||||
#include "tinyformat.h"
|
||||
#include "utiltime.h"
|
||||
|
||||
@ -26,7 +27,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/thread/exceptions.hpp>
|
||||
|
||||
@ -97,20 +97,20 @@ void FileCommit(FILE *file);
|
||||
bool TruncateFile(FILE *file, unsigned int length);
|
||||
int RaiseFileDescriptorLimit(int nMinFD);
|
||||
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
|
||||
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest);
|
||||
bool TryCreateDirectory(const boost::filesystem::path& p);
|
||||
boost::filesystem::path GetDefaultDataDir();
|
||||
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
|
||||
const boost::filesystem::path &GetBackupDir();
|
||||
bool RenameOver(fs::path src, fs::path dest);
|
||||
bool TryCreateDirectory(const fs::path& p);
|
||||
fs::path GetDefaultDataDir();
|
||||
const fs::path &GetDataDir(bool fNetSpecific = true);
|
||||
const fs::path &GetBackupDir();
|
||||
void ClearDatadirCache();
|
||||
boost::filesystem::path GetConfigFile(const std::string& confPath);
|
||||
fs::path GetConfigFile(const std::string& confPath);
|
||||
#ifndef WIN32
|
||||
boost::filesystem::path GetPidFile();
|
||||
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
|
||||
fs::path GetPidFile();
|
||||
void CreatePidFile(const fs::path &path, pid_t pid);
|
||||
#endif
|
||||
void ReadConfigFile(const std::string& confPath);
|
||||
#ifdef WIN32
|
||||
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
||||
fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
||||
#endif
|
||||
void OpenDebugLog();
|
||||
void ShrinkDebugFile();
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include "consensus/validation.h"
|
||||
#include "dogecoin.h"
|
||||
#include "dogecoin-fees.h"
|
||||
#include "fs.h"
|
||||
#include "hash.h"
|
||||
#include "init.h"
|
||||
#include "policy/fees.h"
|
||||
@ -46,8 +47,6 @@
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/math/distributions/poisson.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
@ -3495,8 +3494,8 @@ void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune)
|
||||
{
|
||||
for (std::set<int>::iterator it = setFilesToPrune.begin(); it != setFilesToPrune.end(); ++it) {
|
||||
CDiskBlockPos pos(*it, 0);
|
||||
boost::filesystem::remove(GetBlockPosFilename(pos, "blk"));
|
||||
boost::filesystem::remove(GetBlockPosFilename(pos, "rev"));
|
||||
fs::remove(GetBlockPosFilename(pos, "blk"));
|
||||
fs::remove(GetBlockPosFilename(pos, "rev"));
|
||||
LogPrintf("Prune: %s deleted blk/rev (%05u)\n", __func__, *it);
|
||||
}
|
||||
}
|
||||
@ -3580,7 +3579,7 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight
|
||||
|
||||
bool CheckDiskSpace(uint64_t nAdditionalBytes)
|
||||
{
|
||||
uint64_t nFreeBytesAvailable = boost::filesystem::space(GetDataDir()).available;
|
||||
uint64_t nFreeBytesAvailable = fs::space(GetDataDir()).available;
|
||||
|
||||
// Check for nMinDiskSpace bytes (currently 50MB)
|
||||
if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes)
|
||||
@ -3593,8 +3592,8 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
||||
{
|
||||
if (pos.IsNull())
|
||||
return NULL;
|
||||
boost::filesystem::path path = GetBlockPosFilename(pos, prefix);
|
||||
boost::filesystem::create_directories(path.parent_path());
|
||||
fs::path path = GetBlockPosFilename(pos, prefix);
|
||||
fs::create_directories(path.parent_path());
|
||||
FILE* file = fopen(path.string().c_str(), "rb+");
|
||||
if (!file && !fReadOnly)
|
||||
file = fopen(path.string().c_str(), "wb+");
|
||||
@ -3620,7 +3619,7 @@ FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly) {
|
||||
return OpenDiskFile(pos, "rev", fReadOnly);
|
||||
}
|
||||
|
||||
boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
|
||||
fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
|
||||
{
|
||||
return GetDataDir() / "blocks" / strprintf("%s%05u.dat", prefix, pos.nFile);
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "amount.h"
|
||||
#include "chain.h"
|
||||
#include "coins.h"
|
||||
#include "fs.h"
|
||||
#include "policy/policy.h" // For RECOMMENDED_MIN_TX_FEE
|
||||
#include "protocol.h" // For CMessageHeader::MessageStartChars
|
||||
#include "script/script_error.h"
|
||||
@ -32,7 +33,6 @@
|
||||
#include <atomic>
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
class CBlockIndex;
|
||||
class CBlockTreeDB;
|
||||
@ -263,7 +263,7 @@ FILE* OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly = false);
|
||||
/** Open an undo file (rev?????.dat) */
|
||||
FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly = false);
|
||||
/** Translation to a filesystem path */
|
||||
boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix);
|
||||
fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix);
|
||||
/** Import blocks from an external file */
|
||||
bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskBlockPos *dbp = NULL);
|
||||
/** Initialize a new block tree database + block data on disk */
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "db.h"
|
||||
|
||||
#include "addrman.h"
|
||||
#include "fs.h"
|
||||
#include "hash.h"
|
||||
#include "protocol.h"
|
||||
#include "util.h"
|
||||
@ -17,7 +18,6 @@
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
@ -68,7 +68,7 @@ void CDBEnv::Close()
|
||||
EnvShutdown();
|
||||
}
|
||||
|
||||
bool CDBEnv::Open(const boost::filesystem::path& pathIn)
|
||||
bool CDBEnv::Open(const fs::path& pathIn)
|
||||
{
|
||||
if (fDbEnvInit)
|
||||
return true;
|
||||
@ -76,9 +76,9 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
strPath = pathIn.string();
|
||||
boost::filesystem::path pathLogDir = pathIn / "database";
|
||||
fs::path pathLogDir = pathIn / "database";
|
||||
TryCreateDirectory(pathLogDir);
|
||||
boost::filesystem::path pathErrorFile = pathIn / "db.log";
|
||||
fs::path pathErrorFile = pathIn / "db.log";
|
||||
LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
|
||||
|
||||
unsigned int nEnvFlags = 0;
|
||||
@ -468,7 +468,7 @@ void CDBEnv::Flush(bool fShutdown)
|
||||
dbenv->log_archive(&listp, DB_ARCH_REMOVE);
|
||||
Close();
|
||||
if (!fMockDb)
|
||||
boost::filesystem::remove_all(boost::filesystem::path(strPath) / "database");
|
||||
fs::remove_all(fs::path(strPath) / "database");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#define BITCOIN_WALLET_DB_H
|
||||
|
||||
#include "clientversion.h"
|
||||
#include "fs.h"
|
||||
#include "serialize.h"
|
||||
#include "streams.h"
|
||||
#include "sync.h"
|
||||
@ -16,8 +17,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <db_cxx.h>
|
||||
|
||||
static const unsigned int DEFAULT_WALLET_DBLOGSIZE = 100;
|
||||
@ -67,7 +66,7 @@ public:
|
||||
typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > KeyValPair;
|
||||
bool Salvage(const std::string& strFile, bool fAggressive, std::vector<KeyValPair>& vResult);
|
||||
|
||||
bool Open(const boost::filesystem::path& path);
|
||||
bool Open(const fs::path& path);
|
||||
void Close();
|
||||
void Flush(bool fShutdown);
|
||||
void CheckpointLSN(const std::string& strFile);
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
|
||||
#include "base58.h"
|
||||
#include "chain.h"
|
||||
#include "fs.h"
|
||||
#include "rpc/server.h"
|
||||
#include "init.h"
|
||||
#include "validation.h"
|
||||
@ -23,8 +24,6 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
@ -610,9 +609,9 @@ UniValue dumpwallet(const JSONRPCRequest& request)
|
||||
ofstream file;
|
||||
|
||||
string userFilename = request.params[0].get_str();
|
||||
boost::filesystem::path path = GetBackupDirFromInput(userFilename);
|
||||
fs::path path = GetBackupDirFromInput(userFilename);
|
||||
|
||||
if (boost::filesystem::exists(path))
|
||||
if (fs::exists(path))
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Wallet dump file already exists; not overwriting");
|
||||
|
||||
file.open(path.string());
|
||||
|
||||
@ -4,13 +4,15 @@
|
||||
|
||||
#include "wallet/rpcutil.h"
|
||||
|
||||
boost::filesystem::path GetBackupDirFromInput(std::string strUserFilename)
|
||||
#include "fs.h"
|
||||
|
||||
fs::path GetBackupDirFromInput(std::string strUserFilename)
|
||||
{
|
||||
const boost::filesystem::path backupDir = GetBackupDir();
|
||||
const fs::path backupDir = GetBackupDir();
|
||||
|
||||
if (strUserFilename != "") {
|
||||
boost::filesystem::path p(strUserFilename);
|
||||
boost::filesystem::path filename = p.filename();
|
||||
fs::path p(strUserFilename);
|
||||
fs::path filename = p.filename();
|
||||
|
||||
if (!filename.empty())
|
||||
return backupDir / filename;
|
||||
|
||||
@ -7,9 +7,10 @@
|
||||
*/
|
||||
#ifndef DOGECOIN_WALLET_UTIL_H
|
||||
#define DOGECOIN_WALLET_UTIL_H
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "fs.h"
|
||||
#include "util.h"
|
||||
|
||||
boost::filesystem::path GetBackupDirFromInput(std::string strUserFilename);
|
||||
fs::path GetBackupDirFromInput(std::string strUserFilename);
|
||||
|
||||
#endif // DOGECOIN_WALLET_UTIL_H
|
||||
|
||||
@ -2084,9 +2084,9 @@ UniValue backupwallet(const JSONRPCRequest& request)
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
string userFilename = request.params[0].get_str();
|
||||
boost::filesystem::path path = GetBackupDirFromInput(userFilename);
|
||||
fs::path path = GetBackupDirFromInput(userFilename);
|
||||
|
||||
if (boost::filesystem::exists(path))
|
||||
if (fs::exists(path))
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Wallet dump file already exists; not overwriting");
|
||||
|
||||
if (!pwalletMain->BackupWallet(path.string()))
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "chain.h"
|
||||
#include "dogecoin.h"
|
||||
#include "dogecoin-fees.h"
|
||||
#include "fs.h"
|
||||
#include "wallet/coincontrol.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "consensus/validation.h"
|
||||
@ -32,7 +33,6 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
@ -459,18 +459,18 @@ bool CWallet::Verify()
|
||||
uiInterface.InitMessage(_("Verifying wallet..."));
|
||||
|
||||
// Wallet file must be a plain filename without a directory
|
||||
if (walletFile != boost::filesystem::basename(walletFile) + boost::filesystem::extension(walletFile))
|
||||
if (walletFile != fs::basename(walletFile) + fs::extension(walletFile))
|
||||
return InitError(strprintf(_("Wallet %s resides outside data directory %s"), walletFile, GetDataDir().string()));
|
||||
|
||||
if (!bitdb.Open(GetDataDir()))
|
||||
{
|
||||
// try moving the database env out of the way
|
||||
boost::filesystem::path pathDatabase = GetDataDir() / "database";
|
||||
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%d.bak", GetTime());
|
||||
fs::path pathDatabase = GetDataDir() / "database";
|
||||
fs::path pathDatabaseBak = GetDataDir() / strprintf("database.%d.bak", GetTime());
|
||||
try {
|
||||
boost::filesystem::rename(pathDatabase, pathDatabaseBak);
|
||||
fs::rename(pathDatabase, pathDatabaseBak);
|
||||
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string());
|
||||
} catch (const boost::filesystem::filesystem_error&) {
|
||||
} catch (const fs::filesystem_error&) {
|
||||
// failure is ok (well, not really, but it's not worse than what we started with)
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ bool CWallet::Verify()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(GetDataDir() / walletFile))
|
||||
if (fs::exists(GetDataDir() / walletFile))
|
||||
{
|
||||
CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover);
|
||||
if (r == CDBEnv::RECOVER_OK)
|
||||
@ -4007,25 +4007,25 @@ bool CWallet::BackupWallet(const std::string& strDest)
|
||||
bitdb.mapFileUseCount.erase(strWalletFile);
|
||||
|
||||
// Copy wallet file
|
||||
boost::filesystem::path pathSrc = GetDataDir() / strWalletFile;
|
||||
boost::filesystem::path pathDest(strDest);
|
||||
if (boost::filesystem::is_directory(pathDest))
|
||||
fs::path pathSrc = GetDataDir() / strWalletFile;
|
||||
fs::path pathDest(strDest);
|
||||
if (fs::is_directory(pathDest))
|
||||
pathDest /= strWalletFile;
|
||||
|
||||
try {
|
||||
if (boost::filesystem::equivalent(pathSrc, pathDest)) {
|
||||
if (fs::equivalent(pathSrc, pathDest)) {
|
||||
LogPrintf("cannot backup to wallet source file %s\n", pathDest.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
#if BOOST_VERSION >= 104000
|
||||
boost::filesystem::copy_file(pathSrc, pathDest, boost::filesystem::copy_option::overwrite_if_exists);
|
||||
fs::copy_file(pathSrc, pathDest, fs::copy_option::overwrite_if_exists);
|
||||
#else
|
||||
boost::filesystem::copy_file(pathSrc, pathDest);
|
||||
fs::copy_file(pathSrc, pathDest);
|
||||
#endif
|
||||
LogPrintf("copied %s to %s\n", strWalletFile, pathDest.string());
|
||||
return true;
|
||||
} catch (const boost::filesystem::filesystem_error& e) {
|
||||
} catch (const fs::filesystem_error& e) {
|
||||
LogPrintf("error copying %s to %s - %s\n", strWalletFile, pathDest.string(), e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include <atomic>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user