File indexing completed on 2024-05-05 17:43:12
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Ivan Cukic <ivan.cukic (at) kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "types.h" 0008 0009 #include <QFileInfo> 0010 0011 namespace PlasmaVault 0012 { 0013 static QString normalizePath(const QString &path) 0014 { 0015 QFileInfo fileInfo(path); 0016 0017 auto result = fileInfo.canonicalFilePath(); 0018 0019 if (result.isEmpty()) { 0020 result = path; 0021 } 0022 0023 if (result.endsWith('/')) { 0024 result.chop(1); 0025 } 0026 0027 return result; 0028 } 0029 0030 Device::Device(const QString &device) 0031 : m_device(device) 0032 { 0033 } 0034 0035 QString Device::data() const 0036 { 0037 // Done here because canonicalFilePath relies on file existence 0038 return normalizePath(m_device); 0039 } 0040 0041 MountPoint::MountPoint(const QString &mountPoint) 0042 : m_mountPoint(mountPoint) 0043 { 0044 } 0045 0046 QString MountPoint::data() const 0047 { 0048 // Done here because canonicalFilePath relies on file existence 0049 return normalizePath(m_mountPoint); 0050 } 0051 0052 } // namespace PlasmaVault