Bitcoin ABC 0.30.5
P2P Digital Currency
db.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include <util/fs.h>
7#include <wallet/db.h>
8
9#include <string>
10
11void SplitWalletPath(const fs::path &wallet_path, fs::path &env_directory,
12 std::string &database_filename) {
13 if (fs::is_regular_file(wallet_path)) {
14 // Special case for backwards compatibility: if wallet path points to an
15 // existing file, treat it as the path to a BDB data file in a parent
16 // directory that also contains BDB log files.
17 env_directory = wallet_path.parent_path();
18 database_filename = fs::PathToString(wallet_path.filename());
19 } else {
20 // Normal case: Interpret wallet path as a directory path containing
21 // data and log files.
22 env_directory = wallet_path;
23 database_filename = "wallet.dat";
24 }
25}
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:30
path filename() const
Definition: fs.h:87
static std::string PathToString(const path &path)
Convert path object to byte string.
Definition: fs.h:142
void SplitWalletPath(const fs::path &wallet_path, fs::path &env_directory, std::string &database_filename)
Definition: db.cpp:11