Skip to content

Commit 9ba7c44

Browse files
committed
refactor: get wallet path relative to wallet_dir
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`
1 parent ab25ef8 commit 9ba7c44

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/wallet/db.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

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

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

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

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

0 commit comments

Comments
 (0)