aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/commandlineoptions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenutil/commandlineoptions.cpp')
-rw-r--r--src/zenutil/commandlineoptions.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/zenutil/commandlineoptions.cpp b/src/zenutil/commandlineoptions.cpp
index 0dffa42f0..afef7f6f2 100644
--- a/src/zenutil/commandlineoptions.cpp
+++ b/src/zenutil/commandlineoptions.cpp
@@ -157,12 +157,7 @@ MakeSafeAbsolutePath(const std::filesystem::path& Path)
std::filesystem::path
StringToPath(const std::string_view& Path)
{
- std::string_view UnquotedPath = Path;
-
- if (UnquotedPath.length() > 2 && UnquotedPath.front() == '\"' && UnquotedPath.back() == '\"')
- {
- UnquotedPath = UnquotedPath.substr(1, UnquotedPath.length() - 2);
- }
+ std::string_view UnquotedPath = RemoveQuotes(Path);
if (UnquotedPath.ends_with('/') || UnquotedPath.ends_with('\\') || UnquotedPath.ends_with(std::filesystem::path::preferred_separator))
{
@@ -172,6 +167,19 @@ StringToPath(const std::string_view& Path)
return std::filesystem::path(UnquotedPath).make_preferred();
}
+std::string_view
+RemoveQuotes(const std::string_view& Arg)
+{
+ if (Arg.length() > 2)
+ {
+ if (Arg[0] == '"' && Arg[Arg.length() - 1] == '"')
+ {
+ return Arg.substr(1, Arg.length() - 2);
+ }
+ }
+ return Arg;
+}
+
#if ZEN_WITH_TESTS
void