HomePhabricator

Drop StripRedundantLastElementsOfPath() function

Description

Drop StripRedundantLastElementsOfPath() function

Summary:

Switching to std::filesystems makes possible to leverage std::filesystem::path::lexically_normal and get rid of ugly StripRedundantLastElementsOfPath() crutch.

To make its usage simple and error-proof, a new ArgsManager::GetPathArg() member function introduced which guarantees to return a normalized with no trailing slashes paths provided via -datadir, -blocksdir or -walletdir command-line arguments or configure options.

Re-enable tests disabled in #20744

This should also fix an init error if a -walletdir with a trailing slash
is used on windows. This appears to be a real error and regression
introduced with #20744.

On windows (or at least wine), fs calls that actuallly access the
filesystem like fs::equivalent or fs::exists seem to treat directory
paths with trailing slashes as not existing, so it's necessary to
normalize these paths before using them. This change passes canonical
paths to fs calls validating the -walletdir path to fix this.

Backport of core#24265 and core#24251.

Depends on D11974.

Test Plan:

ninja all check-all

Run the windows cross build tests.

Reviewers: #bitcoin_abc, Fabien, sdulfari

Reviewed By: #bitcoin_abc, sdulfari

Differential Revision: https://reviews.bitcoinabc.org/D13730

Details

Provenance
Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>Authored on Apr 18 2023, 11:46
PiRKCommitted on Apr 21 2023, 14:34
PiRKPushed on Apr 21 2023, 14:34
Reviewer
Restricted Project
Differential Revision
D13730: Drop StripRedundantLastElementsOfPath() function
Parents
rABC1e76484a5e8d: refactor: replace boost::filesystem with std::filesystem
Branches
Unknown
Tags
Unknown