wallet: Add WalletLocation utility class
Github-Pull: #14350
Rebased-From: 01a4c09
This commit is contained in:
parent
1c98a758d0
commit
21693ff0b7
2 changed files with 31 additions and 0 deletions
|
@ -25,3 +25,14 @@ fs::path GetWalletDir()
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WalletLocation::WalletLocation(const std::string& name)
|
||||||
|
: m_name(name)
|
||||||
|
, m_path(fs::absolute(name, GetWalletDir()))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WalletLocation::Exists() const
|
||||||
|
{
|
||||||
|
return fs::symlink_status(m_path).type() != fs::file_not_found;
|
||||||
|
}
|
||||||
|
|
|
@ -11,4 +11,24 @@
|
||||||
//! Get the path of the wallet directory.
|
//! Get the path of the wallet directory.
|
||||||
fs::path GetWalletDir();
|
fs::path GetWalletDir();
|
||||||
|
|
||||||
|
//! The WalletLocation class provides wallet information.
|
||||||
|
class WalletLocation final
|
||||||
|
{
|
||||||
|
std::string m_name;
|
||||||
|
fs::path m_path;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit WalletLocation() {}
|
||||||
|
explicit WalletLocation(const std::string& name);
|
||||||
|
|
||||||
|
//! Get wallet name.
|
||||||
|
const std::string& GetName() const { return m_name; }
|
||||||
|
|
||||||
|
//! Get wallet absolute path.
|
||||||
|
const fs::path& GetPath() const { return m_path; }
|
||||||
|
|
||||||
|
//! Return whether the wallet exists.
|
||||||
|
bool Exists() const;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_WALLET_WALLETUTIL_H
|
#endif // BITCOIN_WALLET_WALLETUTIL_H
|
||||||
|
|
Loading…
Reference in a new issue