Should be enough to repair the package install/uninstall in the mobile
case. svn path=/trunk/KDE/kdelibs/; revision=1185886
This commit is contained in:
parent
fc07638805
commit
83fba085c0
70
package.cpp
70
package.cpp
@ -58,6 +58,69 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
#ifdef PLASMA_NO_KIO // Provide some convenience for dealing with folders
|
||||
|
||||
bool copyFolder(QString sourcePath, QString targetPath)
|
||||
{
|
||||
QDir source(sourcePath);
|
||||
if(!source.exists())
|
||||
return false;
|
||||
|
||||
QDir target(targetPath);
|
||||
if(!target.exists()) {
|
||||
QString targetName = target.dirName();
|
||||
target.cdUp();
|
||||
target.mkdir(targetName);
|
||||
target = QDir(targetPath);
|
||||
}
|
||||
|
||||
foreach (const QString &fileName, source.entryList(QDir::Files)) {
|
||||
QString sourceFilePath = sourcePath + QDir::separator() + fileName;
|
||||
QString targetFilePath = targetPath + QDir::separator() + fileName;
|
||||
|
||||
if (!QFile::copy(sourceFilePath, targetFilePath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QString &subFolderName, source.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)) {
|
||||
QString sourceSubFolderPath = sourcePath + QDir::separator() + subFolderName;
|
||||
QString targetSubFolderPath = targetPath + QDir::separator() + subFolderName;
|
||||
|
||||
if (!copyFolder(sourceSubFolderPath, targetSubFolderPath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool removeFolder(QString folderPath)
|
||||
{
|
||||
QDir folder(folderPath);
|
||||
if(!folder.exists())
|
||||
return false;
|
||||
|
||||
foreach (const QString &fileName, folder.entryList(QDir::Files)) {
|
||||
if (!QFile::remove(folderPath + QDir::separator() + fileName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QString &subFolderName, folder.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)) {
|
||||
if (!removeFolder(folderPath + QDir::separator() + subFolderName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString folderName = folder.dirName();
|
||||
folder.cdUp();
|
||||
return folder.rmdir(folderName);
|
||||
}
|
||||
|
||||
#endif // PLASMA_NO_KIO
|
||||
|
||||
|
||||
Package::Package()
|
||||
: d(new PackagePrivate(PackageStructure::Ptr(0), QString()))
|
||||
{
|
||||
@ -447,7 +510,8 @@ bool Package::installPackage(const QString &package,
|
||||
const bool ok = job->exec();
|
||||
const QString errorString = job->errorString();
|
||||
#else
|
||||
const bool ok = QFile::rename(path, targetName);
|
||||
const bool ok = copyFolder(path, targetName);
|
||||
removeFolder(path);
|
||||
const QString errorString("unknown");
|
||||
#endif
|
||||
if (!ok) {
|
||||
@ -462,7 +526,7 @@ bool Package::installPackage(const QString &package,
|
||||
const bool ok = job->exec();
|
||||
const QString errorString = job->errorString();
|
||||
#else
|
||||
const bool ok = false; // Qt dunno how to recursively copy directories, so don't bother
|
||||
const bool ok = copyFolder(path, targetName);
|
||||
const QString errorString("unknown");
|
||||
#endif
|
||||
if (!ok) {
|
||||
@ -546,7 +610,7 @@ bool Package::uninstallPackage(const QString &pluginName,
|
||||
ok = job->exec();
|
||||
const QString errorString = job->errorString();
|
||||
#else
|
||||
ok = QFile::remove(targetName);
|
||||
ok = removeFolder(targetName);
|
||||
const QString errorString("unknown");
|
||||
#endif
|
||||
if (!ok) {
|
||||
|
Loading…
Reference in New Issue
Block a user