aboutsummaryrefslogtreecommitdiff
path: root/src/util/system.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-04 17:57:51 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-09 19:31:16 +0200
commit540ca5111f7dc91a9808e41ccb4446d8dc0a1bec (patch)
tree9d956753b4de73919e9cbf1fd68490bc4440b113 /src/util/system.cpp
parent5e8e0b3d7f6055e326bda61e60712b530e8920f0 (diff)
downloadbitcoin-540ca5111f7dc91a9808e41ccb4446d8dc0a1bec.tar.xz
util: Add ArgsManager::GetPathArg() function
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Diffstat (limited to 'src/util/system.cpp')
-rw-r--r--src/util/system.cpp7
1 files changed, 7 insertions, 0 deletions
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<unsigned int> 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);