aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-10-26 13:23:47 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-10-26 13:25:35 +0200
commitd50c996a147dd608b17beb8984f2bc293c67497e (patch)
treedb4fcadc4bc4d2b22b3906e316b5399e96b8cf94 /src
parent9d4541508b981eb7f05c0b9f1d94a698e4aab1d2 (diff)
parented2e18398b3ab657e98e3e1fe135cbf8dd94fda3 (diff)
downloadbitcoin-d50c996a147dd608b17beb8984f2bc293c67497e.tar.xz
Merge #14561: Remove fs::relative call and fix listwalletdir tests
ed2e18398b3ab657e98e3e1fe135cbf8dd94fda3 Remove fs::relative call and fix listwalletdir tests (João Barbosa) Pull request description: The implementation of `fs::relative` resolves symlinks which is not intended in ListWalletDir. The replacement does what is required, and `listwalletdir` RPC tests are fixed accordingly. Also, `fs::recursive_directory_iterator` iteration is fixed to build with boost 1.47. Based on #14559 Tree-SHA512: 1da516226073f195285d10d9d9648c90cce0158c5d1eb9c31217bb4abb575cd37f07c00787c5a850554d6120bbc5a3cbc5cb47d4488b32ac6bcb52bc1882d600
Diffstat (limited to 'src')
-rw-r--r--src/wallet/walletutil.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp
index c0c9afe13e..d66d8a3775 100644
--- a/src/wallet/walletutil.cpp
+++ b/src/wallet/walletutil.cpp
@@ -52,12 +52,17 @@ static bool IsBerkeleyBtree(const fs::path& path)
std::vector<fs::path> ListWalletDir()
{
const fs::path wallet_dir = GetWalletDir();
+ const size_t offset = wallet_dir.string().size() + 1;
std::vector<fs::path> paths;
- for (auto it = fs::recursive_directory_iterator(wallet_dir); it != end(it); ++it) {
+ for (auto it = fs::recursive_directory_iterator(wallet_dir); it != fs::recursive_directory_iterator(); ++it) {
+ // Get wallet path relative to walletdir by removing walletdir from the wallet path.
+ // This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
+ const fs::path path = it->path().string().substr(offset);
+
if (it->status().type() == fs::directory_file && IsBerkeleyBtree(it->path() / "wallet.dat")) {
// Found a directory which contains wallet.dat btree file, add it as a wallet.
- paths.emplace_back(fs::relative(it->path(), wallet_dir));
+ paths.emplace_back(path);
} else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && IsBerkeleyBtree(it->path())) {
if (it->path().filename() == "wallet.dat") {
// Found top-level wallet.dat btree file, add top level directory ""
@@ -68,7 +73,7 @@ std::vector<fs::path> ListWalletDir()
// software will never create these files but will allow them to be
// opened in a shared database environment for backwards compatibility.
// Add it to the list of available wallets.
- paths.emplace_back(fs::relative(it->path(), wallet_dir));
+ paths.emplace_back(path);
}
}
}