diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-11-05 13:17:01 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-11-05 13:17:03 +0100 |
commit | 46eb2755d456ca736c1cb7a0922bfece63c5151e (patch) | |
tree | e70dbc130a17b3ddd842ce8d47b671a6b31873bf /src/wallet/walletutil.cpp | |
parent | 69d574ac6c24d85f1f1947bd67cb8c44c2a5f290 (diff) | |
parent | 65f3672f3b82a6fa30e5171f85bc8d8a29e0797e (diff) |
Merge #14350: Add WalletLocation class
65f3672f3b82a6fa30e5171f85bc8d8a29e0797e wallet: Refactor to use WalletLocation (João Barbosa)
01a4c095c87500650663341533f000c6b613e9da wallet: Add WalletLocation utility class (João Barbosa)
Pull request description:
Advantages of this change:
- avoid resolving wallet absolute path and name repetitively and in multiple places;
- avoid calling `GetWalletDir` in multiple places;
- extract these details from the actual wallet implementation.
The `WalletLocation` class can be a way to represent a wallet not yet loaded that exists in the wallet directory.
Tree-SHA512: 71ec09786e038499710e7acafe92d66ab9883fc894964e267443ae9c10a6872a10995c3987a169c436a4e793dae96b28fb97bd7f78483c4b72ac930fa23f8686
Diffstat (limited to 'src/wallet/walletutil.cpp')
-rw-r--r-- | src/wallet/walletutil.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index feb952c733..6db4c63acb 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -80,3 +80,14 @@ std::vector<fs::path> ListWalletDir() return paths; } + +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; +} |