#define VERSION_C
constexpr auto versionC = "version";
#endif
+
+QString trailingSlashPath(const QString &path)
+{
+ return path.endsWith('/') ? path : QString(path + QStringLiteral("/"));
+}
}
+
namespace OCC {
Q_LOGGING_CATEGORY(lcFolder, "nextcloud.gui.folder", QtInfoMsg)
if (_canonicalLocalPath.isEmpty()) {
qCWarning(lcFolder) << "Broken symlink:" << _definition.localPath;
_canonicalLocalPath = _definition.localPath;
- } else if (!_canonicalLocalPath.endsWith('/')) {
- _canonicalLocalPath.append('/');
}
+ _canonicalLocalPath = trailingSlashPath(_canonicalLocalPath);
+
if (fi.isDir() && fi.isReadable()) {
qCDebug(lcFolder) << "Checked local path ok";
} else {
QString Folder::shortGuiLocalPath() const
{
QString p = _definition.localPath;
- QString home = QDir::homePath();
- if (!home.endsWith('/')) {
- home.append('/');
- }
+ const auto home = trailingSlashPath(QDir::homePath());
+
if (p.startsWith(home)) {
p = p.mid(home.length());
}
QString Folder::remotePathTrailingSlash() const
{
- QString result = remotePath();
- if (!result.endsWith('/'))
- result.append('/');
- return result;
+ return trailingSlashPath(remotePath());
}
QUrl Folder::remoteUrl() const
void Folder::slotNewBigFolderDiscovered(const QString &newF, bool isExternal)
{
- auto newFolder = newF;
- if (!newFolder.endsWith(QLatin1Char('/'))) {
- newFolder += QLatin1Char('/');
- }
+ const auto newFolder = trailingSlashPath(newF);
auto journal = journalDb();
// Add the entry to the blacklist if it is neither in the blacklist or whitelist already
}
if (!parentPathEncrypted) {
- const auto pathAdjusted = rec._path.endsWith('/') ? rec._path : QString(rec._path + QStringLiteral("/"));
+ const auto pathAdjusted = trailingSlashPath(rec._path);
e2eFoldersToBlacklist.append(pathAdjusted);
}
}
QString FolderDefinition::prepareLocalPath(const QString &path)
{
- QString p = QDir::fromNativeSeparators(path);
- if (!p.endsWith(QLatin1Char('/'))) {
- p.append(QLatin1Char('/'));
- }
- return p;
+ const auto normalisedPath = QDir::fromNativeSeparators(path);
+ return trailingSlashPath(normalisedPath);
}
QString FolderDefinition::prepareTargetPath(const QString &path)