* make it possible to get a list of installed packages by path rather than package name
* allow the basePath to be a symlink svn path=/trunk/KDE/kdelibs/; revision=906191
This commit is contained in:
parent
be4c8c2c5e
commit
8dd6e79e56
36
package.cpp
36
package.cpp
@ -48,12 +48,20 @@ class PackagePrivate
|
||||
public:
|
||||
PackagePrivate(const PackageStructure::Ptr st, const QString &p)
|
||||
: structure(st),
|
||||
basePath(p),
|
||||
valid(QFile::exists(basePath))
|
||||
basePath(p)
|
||||
{
|
||||
QDir dir(basePath);
|
||||
basePath = dir.canonicalPath();
|
||||
valid = QFile::exists(basePath);
|
||||
|
||||
if (valid) {
|
||||
QFileInfo info(basePath);
|
||||
if (valid && info.isDir() && basePath[basePath.length() - 1] != '/') {
|
||||
basePath.append('/');
|
||||
if (info.isDir()) {
|
||||
basePath.append(QDir::separator());
|
||||
}
|
||||
kDebug() << "basePath is" << basePath;
|
||||
} else {
|
||||
kDebug() << p << "invalid, basePath is" << basePath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,6 +220,26 @@ QStringList Package::listInstalled(const QString &packageRoot) // static
|
||||
return packages;
|
||||
}
|
||||
|
||||
QStringList Package::listInstalledPaths(const QString &packageRoot) // static
|
||||
{
|
||||
QDir dir(packageRoot);
|
||||
|
||||
if (!dir.exists()) {
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList packages;
|
||||
|
||||
foreach (const QString &sdir, dir.entryList(QDir::AllDirs | QDir::Readable)) {
|
||||
QString metadata = packageRoot + '/' + sdir + "/metadata.desktop";
|
||||
if (QFile::exists(metadata)) {
|
||||
packages << sdir;
|
||||
}
|
||||
}
|
||||
|
||||
return packages;
|
||||
}
|
||||
|
||||
bool Package::installPackage(const QString &package,
|
||||
const QString &packageRoot,
|
||||
const QString &servicePrefix) // static
|
||||
|
11
package.h
11
package.h
@ -114,7 +114,7 @@ class PLASMA_EXPORT Package
|
||||
const PackageStructure::Ptr structure() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all installed packages
|
||||
* Returns a list of all installed packages by name
|
||||
*
|
||||
* @param packageRoot path to the directory where Plasmagik packages
|
||||
* have been installed to
|
||||
@ -122,6 +122,15 @@ class PLASMA_EXPORT Package
|
||||
**/
|
||||
static QStringList listInstalled(const QString &packageRoot);
|
||||
|
||||
/**
|
||||
* Returns a list of all paths of installed packages in the given root
|
||||
*
|
||||
* @param packageRoot path to the directory where Plasmagik packages
|
||||
* have been installed to
|
||||
* @return a list of installed Plasmagik packages by path
|
||||
**/
|
||||
static QStringList listInstalledPaths(const QString &packageRoot);
|
||||
|
||||
/**
|
||||
* Installs a package.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user