File: kuputils.cpp

package info (click to toggle)
kup-backup 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,576 kB
  • sloc: cpp: 8,422; xml: 311; makefile: 6; sh: 3
file content (26 lines) | stat: -rw-r--r-- 583 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
//
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL

#include "kuputils.h"

#include <QDir>

void ensureTrailingSlash(QString &pPath)
{
    if (!pPath.endsWith(QDir::separator())) {
        pPath.append(QDir::separator());
    }
}

void ensureNoTrailingSlash(QString &pPath)
{
    while (pPath.endsWith(QDir::separator())) {
        pPath.chop(1);
    }
}

QString lastPartOfPath(const QString &pPath)
{
    return pPath.section(QDir::separator(), -1, -1, QString::SectionSkipEmpty);
}