From 540ca5111f7dc91a9808e41ccb4446d8dc0a1bec Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 4 Feb 2022 17:57:51 +0200 Subject: util: Add ArgsManager::GetPathArg() function Co-authored-by: Ryan Ofsky --- src/util/system.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/util/system.cpp') diff --git a/src/util/system.cpp b/src/util/system.cpp index 4ead39dd6c..82770dc665 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -399,6 +399,13 @@ std::optional ArgsManager::GetArgFlags(const std::string& name) co return std::nullopt; } +fs::path ArgsManager::GetPathArg(std::string pathlike_arg) const +{ + auto result = fs::PathFromString(GetArg(pathlike_arg, "")).lexically_normal(); + // Remove trailing slash, if present. + return result.has_filename() ? result : result.parent_path(); +} + const fs::path& ArgsManager::GetBlocksDirPath() const { LOCK(cs_args); -- cgit v1.2.3