Skip to content

Commit

Permalink
refactor: get wallet path relative to wallet_dir
Browse files Browse the repository at this point in the history
Now that boost has been updated > 1.60, we can simplify how we get
wallet path relative to wallet_dir by using:
`boost::filesystem::lexically_relative`
  • Loading branch information
mjdietzx committed Oct 29, 2021
1 parent ab25ef8 commit 9ba7c44
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/wallet/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
{
const size_t offset = wallet_dir.native().size() + (wallet_dir == wallet_dir.root_name() ? 0 : 1);
std::vector<fs::path> paths;
boost::system::error_code ec;

Expand All @@ -28,10 +27,7 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
}

try {
// Get wallet path relative to walletdir by removing walletdir from the wallet path.
// This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
const auto path_str = it->path().native().substr(offset);
const fs::path path{path_str.begin(), path_str.end()};
const fs::path path{it->path().lexically_relative(wallet_dir)};

if (it->status().type() == fs::directory_file &&
(IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) {
Expand Down

0 comments on commit 9ba7c44

Please sign in to comment.