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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/*
SPDX-FileCopyrightText: 2002, 2003 Stephan Kulow <coolo@kde.org>
SPDX-FileCopyrightText: 2003 David Faure <faure@kde.org>
SPDX-License-Identifier: LGPL-2.0-only
*/
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QUrl>
#include <kmountpoint.h>
// This is a test program for KMountPoint
// Call it with either a device path or a mount point.
// It will try both, so obviously one will fail.
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QUrl url;
if (argc > 1) {
url = QUrl::fromUserInput(argv[1]);
} else {
url = QUrl::fromLocalFile(QDir::currentPath());
}
const KMountPoint::List mountPoints = KMountPoint::currentMountPoints();
KMountPoint::Ptr mp = mountPoints.findByDevice(url.toLocalFile());
if (!mp) {
qDebug() << "no mount point for device" << url << "found";
} else {
qDebug() << mp->mountPoint() << "is the mount point for device" << url;
}
mp = mountPoints.findByPath(url.toLocalFile());
if (!mp) {
qDebug() << "no mount point for path" << url << "found";
} else {
qDebug() << mp->mountPoint() << "is the mount point for path" << url;
qDebug() << url << "is probably" << (mp->probablySlow() ? "slow" : "normal") << "mounted";
}
url = QUrl::fromLocalFile(QDir::homePath());
mp = mountPoints.findByPath(url.toLocalFile());
if (!mp) {
qDebug() << "no mount point for path" << url << "found";
} else {
qDebug() << mp->mountPoint() << "is the mount point for path" << url;
}
return 0;
}
|