From 1012a0b0092f2c872df5ed6b2a143e25418aadc8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 11 Oct 2023 15:36:09 +0800 Subject: [PATCH] Add utility method to remove leading slashes from paths Signed-off-by: Claudio Cambra --- src/common/utility.cpp | 7 +++++++ src/common/utility.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/common/utility.cpp b/src/common/utility.cpp index 61f2489e4255b..607bb0414ec7c 100644 --- a/src/common/utility.cpp +++ b/src/common/utility.cpp @@ -729,4 +729,11 @@ QString Utility::trailingSlashPath(const QString &path) return path.endsWith(slash) ? path : QString(path + slash); } +QString Utility::noLeadingSlashPath(const QString &path) +{ + static const auto slash = QLatin1Char('/'); + return path.startsWith(slash) ? path.mid(1) : path; +} + + } // namespace OCC diff --git a/src/common/utility.h b/src/common/utility.h index b554a196be189..e19f0da6ae1ee 100644 --- a/src/common/utility.h +++ b/src/common/utility.h @@ -256,6 +256,7 @@ namespace Utility { OCSYNC_EXPORT void registerUriHandlerForLocalEditing(); OCSYNC_EXPORT QString trailingSlashPath(const QString &path); + OCSYNC_EXPORT QString noLeadingSlashPath(const QString &path); #ifdef Q_OS_WIN OCSYNC_EXPORT bool registryKeyExists(HKEY hRootKey, const QString &subKey);