Skip to content

Commit

Permalink
wallet: Add WalletLocation utility class
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Oct 25, 2018
1 parent 613fc95 commit 01a4c09
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/wallet/walletutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,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;
}
20 changes: 20 additions & 0 deletions src/wallet/walletutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,24 @@ fs::path GetWalletDir();
//! Get wallets in wallet directory.
std::vector<fs::path> ListWalletDir();

//! 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

0 comments on commit 01a4c09

Please sign in to comment.