Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletutil.cpp
// Copyright (c) 2017 The Bitcoin Core developers | // Copyright (c) 2017 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <wallet/walletutil.h> | #include <wallet/walletutil.h> | ||||
#include <logging.h> | #include <logging.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
bool ExistsBerkeleyDatabase(const fs::path &path); | bool ExistsBerkeleyDatabase(const fs::path &path); | ||||
bool ExistsSQLiteDatabase(const fs::path &path); | |||||
fs::path GetWalletDir() { | fs::path GetWalletDir() { | ||||
fs::path path; | fs::path path; | ||||
if (gArgs.IsArgSet("-walletdir")) { | if (gArgs.IsArgSet("-walletdir")) { | ||||
path = gArgs.GetArg("-walletdir", ""); | path = gArgs.GetArg("-walletdir", ""); | ||||
if (!fs::is_directory(path)) { | if (!fs::is_directory(path)) { | ||||
// If the path specified doesn't exist, we return the deliberately | // If the path specified doesn't exist, we return the deliberately | ||||
Show All 27 Lines | for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); | ||||
} | } | ||||
// Get wallet path relative to walletdir by removing walletdir from the | // Get wallet path relative to walletdir by removing walletdir from the | ||||
// wallet path. This can be replaced by | // wallet path. This can be replaced by | ||||
// boost::filesystem::lexically_relative once boost is bumped to 1.60. | // boost::filesystem::lexically_relative once boost is bumped to 1.60. | ||||
const fs::path path = it->path().string().substr(offset); | const fs::path path = it->path().string().substr(offset); | ||||
if (it->status().type() == fs::directory_file && | if (it->status().type() == fs::directory_file && | ||||
ExistsBerkeleyDatabase(it->path())) { | (ExistsBerkeleyDatabase(it->path()) || | ||||
ExistsSQLiteDatabase(it->path()))) { | |||||
// Found a directory which contains wallet.dat btree file, add it as | // Found a directory which contains wallet.dat btree file, add it as | ||||
// a wallet. | // a wallet. | ||||
paths.emplace_back(path); | paths.emplace_back(path); | ||||
} else if (it.level() == 0 && | } else if (it.level() == 0 && | ||||
it->symlink_status().type() == fs::regular_file && | it->symlink_status().type() == fs::regular_file && | ||||
ExistsBerkeleyDatabase(it->path())) { | ExistsBerkeleyDatabase(it->path())) { | ||||
if (it->path().filename() == "wallet.dat") { | if (it->path().filename() == "wallet.dat") { | ||||
// Found top-level wallet.dat btree file, add top level | // Found top-level wallet.dat btree file, add top level | ||||
Show All 15 Lines |