Skip to content

Commit ef802ef

Browse files
committed
Merge #15880: utils and libraries: Replace deprecated Boost Filesystem functions
a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov) 4f65af9 Remove dead code for walletFile check (Hennadii Stepanov) Pull request description: Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions). See more: https://lists.boost.org/Archives/boost/2010/01/160905.php Also this PR prevents further use of deprecated Boost Filesystem functions. Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains: ```c++ # ifndef BOOST_FILESYSTEM_NO_DEPRECATED inline std::string extension(const path & p) { return p.extension().string(); } inline std::string basename(const path & p) { return p.stem().string(); } inline path change_extension( const path & p, const path & new_extension ) { path new_p( p ); new_p.replace_extension( new_extension ); return new_p; } # endif ``` UPDATE: Also removed unused code as [noted](bitcoin/bitcoin#15880 (comment)) by **ryanofsky**. ACKs for commit a0a222: Empact: utACK bitcoin/bitcoin@a0a222e practicalswift: utACK a0a222e fanquake: utACK a0a222e ryanofsky: utACK a0a222e. Only change is dropping assert and squashing first two commits. Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
2 parents b2a6b02 + a0a222e commit ef802ef

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

src/dbwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static leveldb::Options GetOptions(size_t nCacheSize)
115115
}
116116

117117
CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bool fWipe, bool obfuscate)
118-
: m_name(fs::basename(path))
118+
: m_name{path.stem().string()}
119119
{
120120
penv = nullptr;
121121
readoptions.verify_checksums = true;

src/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <ext/stdio_filebuf.h>
1212
#endif
1313

14+
#define BOOST_FILESYSTEM_NO_DEPRECATED
1415
#include <boost/filesystem.hpp>
1516
#include <boost/filesystem/fstream.hpp>
1617

src/wallet/db.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,6 @@ bool BerkeleyBatch::VerifyEnvironment(const fs::path& file_path, std::string& er
407407
LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(nullptr, nullptr, nullptr));
408408
LogPrintf("Using wallet %s\n", file_path.string());
409409

410-
// Wallet file must be a plain filename without a directory
411-
if (walletFile != fs::basename(walletFile) + fs::extension(walletFile))
412-
{
413-
errorStr = strprintf(_("Wallet %s resides outside wallet directory %s"), walletFile, walletDir.string());
414-
return false;
415-
}
416-
417410
if (!env->Open(true /* retry */)) {
418411
errorStr = strprintf(_("Error initializing wallet database environment %s!"), walletDir);
419412
return false;

0 commit comments

Comments
 (0)