aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-03-01 16:28:39 +0000
committerWladimir J. van der Laan <laanwj@gmail.com>2017-04-03 12:32:32 +0200
commit2a5f574762614b74dee738392057200dd28c64fb (patch)
tree7b47462778a6dd5964eb0c2cc332276581b2615e /src/validation.cpp
parentbac5c9cf643e9333479ac667426d0b70f8f3aa7f (diff)
downloadbitcoin-2a5f574762614b74dee738392057200dd28c64fb.tar.xz
Use fsbridge for fopen and freopen
Abstracts away how a path is opened to a `FILE*`. Reduces the number of places where path is converted to a string for anything else but printing.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 0b55e1db1b..03bae31d9e 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -3414,9 +3414,9 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
return NULL;
fs::path path = GetBlockPosFilename(pos, prefix);
fs::create_directories(path.parent_path());
- FILE* file = fopen(path.string().c_str(), "rb+");
+ FILE* file = fsbridge::fopen(path, "rb+");
if (!file && !fReadOnly)
- file = fopen(path.string().c_str(), "wb+");
+ file = fsbridge::fopen(path, "wb+");
if (!file) {
LogPrintf("Unable to open file %s\n", path.string());
return NULL;
@@ -4164,7 +4164,7 @@ static const uint64_t MEMPOOL_DUMP_VERSION = 1;
bool LoadMempool(void)
{
int64_t nExpiryTimeout = GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60;
- FILE* filestr = fopen((GetDataDir() / "mempool.dat").string().c_str(), "rb");
+ FILE* filestr = fsbridge::fopen(GetDataDir() / "mempool.dat", "rb");
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION);
if (file.IsNull()) {
LogPrintf("Failed to open mempool file from disk. Continuing anyway.\n");
@@ -4244,7 +4244,7 @@ void DumpMempool(void)
int64_t mid = GetTimeMicros();
try {
- FILE* filestr = fopen((GetDataDir() / "mempool.dat.new").string().c_str(), "wb");
+ FILE* filestr = fsbridge::fopen(GetDataDir() / "mempool.dat.new", "wb");
if (!filestr) {
return;
}