File indexing completed on 2025-02-09 04:24:43
0001 /* 0002 SPDX-FileCopyrightText: 2002, 2003 Stephan Kulow <coolo@kde.org> 0003 SPDX-FileCopyrightText: 2003 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #include <QCoreApplication> 0009 #include <QDebug> 0010 #include <QDir> 0011 #include <QUrl> 0012 #include <kmountpoint.h> 0013 0014 // This is a test program for KMountPoint 0015 0016 // Call it with either a device path or a mount point. 0017 // It will try both, so obviously one will fail. 0018 0019 int main(int argc, char **argv) 0020 { 0021 QCoreApplication app(argc, argv); 0022 0023 QUrl url; 0024 if (argc > 1) { 0025 url = QUrl::fromUserInput(QString::fromUtf8(argv[1])); 0026 } else { 0027 url = QUrl::fromLocalFile(QDir::currentPath()); 0028 } 0029 0030 const KMountPoint::List mountPoints = KMountPoint::currentMountPoints(); 0031 0032 KMountPoint::Ptr mp = mountPoints.findByDevice(url.toLocalFile()); 0033 if (!mp) { 0034 qDebug() << "no mount point for device" << url << "found"; 0035 } else { 0036 qDebug() << mp->mountPoint() << "is the mount point for device" << url; 0037 } 0038 0039 mp = mountPoints.findByPath(url.toLocalFile()); 0040 if (!mp) { 0041 qDebug() << "no mount point for path" << url << "found"; 0042 } else { 0043 qDebug() << mp->mountPoint() << "is the mount point for path" << url; 0044 qDebug() << url << "is probably" << (mp->probablySlow() ? "slow" : "normal") << "mounted"; 0045 } 0046 0047 url = QUrl::fromLocalFile(QDir::homePath()); 0048 0049 mp = mountPoints.findByPath(url.toLocalFile()); 0050 if (!mp) { 0051 qDebug() << "no mount point for path" << url << "found"; 0052 } else { 0053 qDebug() << mp->mountPoint() << "is the mount point for path" << url; 0054 } 0055 0056 return 0; 0057 }