Merge pull request #1270

fdef09f Wallet API: make sure path exists before searching for wallets (Jacob Brydolf)
This commit is contained in:
Riccardo Spagni 2016-10-29 11:35:48 +02:00
commit 83b0511731
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 5 additions and 2 deletions

View File

@ -88,10 +88,13 @@ bool WalletManagerImpl::walletExists(const std::string &path)
std::vector<std::string> WalletManagerImpl::findWallets(const std::string &path)
{
std::vector<std::string> result;
boost::filesystem::path work_dir(path);
// return empty result if path doesn't exist
if(!boost::filesystem::is_directory(path)){
return result;
}
const boost::regex wallet_rx("(.*)\\.(keys)$"); // searching for <wallet_name>.keys files
boost::filesystem::recursive_directory_iterator end_itr; // Default ctor yields past-the-end
boost::filesystem::path work_dir(path);
for (boost::filesystem::recursive_directory_iterator itr(path); itr != end_itr; ++itr) {
// Skip if not a file
if (!boost::filesystem::is_regular_file(itr->status()))