From 595f5c3ca386b2ceeba11ade6fdab336b5014a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Fri, 28 Sep 2018 12:50:04 +0100 Subject: [PATCH] wallet: Add WalletLocation utility class Github-Pull: #14350 Rebased-From: 01a4c09 --- src/wallet/walletutil.cpp | 11 +++++++++++ src/wallet/walletutil.h | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index 04c2407a8..baf8e7057 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -102,3 +102,14 @@ bool WalletLocation::Exists() const { return fs::symlink_status(m_path).type() != fs::file_not_found; } + +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; +} diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h index ba2f91384..db1e54e00 100644 --- a/src/wallet/walletutil.h +++ b/src/wallet/walletutil.h @@ -35,4 +35,24 @@ public: bool Exists() const; }; +//! 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