2010-08-29 12:58:15 -04:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2020-01-14 16:17:38 -03:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 10:02:28 -04:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2010-08-29 12:58:15 -04:00
|
|
|
|
2020-06-15 14:29:29 -04:00
|
|
|
#include <fs.h>
|
2017-11-09 21:57:53 -03:00
|
|
|
#include <wallet/db.h>
|
2013-04-13 02:13:08 -03:00
|
|
|
|
2020-06-15 14:29:29 -04:00
|
|
|
#include <string>
|
2018-09-25 10:56:16 -03:00
|
|
|
|
2020-06-15 14:14:51 -04:00
|
|
|
void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename)
|
2017-11-13 23:25:46 -03:00
|
|
|
{
|
2017-11-15 17:44:36 -03:00
|
|
|
if (fs::is_regular_file(wallet_path)) {
|
|
|
|
// Special case for backwards compatibility: if wallet path points to an
|
|
|
|
// existing file, treat it as the path to a BDB data file in a parent
|
|
|
|
// directory that also contains BDB log files.
|
|
|
|
env_directory = wallet_path.parent_path();
|
|
|
|
database_filename = wallet_path.filename().string();
|
|
|
|
} else {
|
|
|
|
// Normal case: Interpret wallet path as a directory path containing
|
|
|
|
// data and log files.
|
|
|
|
env_directory = wallet_path;
|
|
|
|
database_filename = "wallet.dat";
|
|
|
|
}
|
2018-10-23 02:26:27 -03:00
|
|
|
}
|