Bitcoin ABC  0.22.13
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 <fs.h>
7 #include <wallet/db.h>
8 
9 #include <string>
10 
11 void 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 = wallet_path.filename().string();
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 }
26 
27 fs::path WalletDataFilePath(const fs::path &wallet_path) {
28  fs::path env_directory;
29  std::string database_filename;
30  SplitWalletPath(wallet_path, env_directory, database_filename);
31  return env_directory / database_filename;
32 }
void SplitWalletPath(const fs::path &wallet_path, fs::path &env_directory, std::string &database_filename)
Definition: db.cpp:11
fs::path WalletDataFilePath(const fs::path &wallet_path)
Given a wallet directory path or legacy file path, return path to main data file in the wallet databa...
Definition: db.cpp:27