summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/uninstall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/uninstall.cpp')
-rw-r--r--rbutil/rbutilqt/uninstall.cpp39
1 files changed, 8 insertions, 31 deletions
diff --git a/rbutil/rbutilqt/uninstall.cpp b/rbutil/rbutilqt/uninstall.cpp
index ad31e1db38..2e96d49081 100644
--- a/rbutil/rbutilqt/uninstall.cpp
+++ b/rbutil/rbutilqt/uninstall.cpp
@@ -16,11 +16,11 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19
20#include "uninstall.h"
21 19
20#include "uninstall.h"
21#include "utils.h"
22 22
23Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent) 23Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
24{ 24{
25 m_mountpoint = mountpoint; 25 m_mountpoint = mountpoint;
26} 26}
@@ -37,45 +37,22 @@ void Uninstaller::deleteAll(ProgressloggerInterface* dp)
37 m_dp->addItem(tr("Finished Uninstallation"),LOGOK); 37 m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
38 m_dp->abort(); 38 m_dp->abort();
39} 39}
40// recursiv function to delete a dir with files
41bool Uninstaller::recRmdir( QString &dirName )
42{
43 QString dirN = dirName;
44 QDir dir(dirN);
45 QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
46 QFileInfo fileInfo;
47 QString curItem, lstAt;
48 for(int i = 0; i < list.size(); i++){ // loop through all items of list
49 QString name = list.at(i);
50 if(!(name == ".") && !(name == "..")){
51 curItem = dirN + "/" + name;
52 fileInfo.setFile(curItem);
53 if(fileInfo.isDir()) // is directory
54 recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
55 else // is file
56 QFile::remove(curItem); // ok, delete file
57 }
58 }
59 dir.cdUp();
60 return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
61}
62
63 40
64void Uninstaller::uninstall(ProgressloggerInterface* dp) 41void Uninstaller::uninstall(ProgressloggerInterface* dp)
65{ 42{
66 m_dp = dp; 43 m_dp = dp;
67 m_dp->setProgressMax(0); 44 m_dp->setProgressMax(0);
68 m_dp->addItem(tr("Starting Uninstallation"),LOGINFO); 45 m_dp->addItem(tr("Starting Uninstallation"),LOGINFO);
69 46
70 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); 47 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
71 48
72 for(int i=0; i< uninstallSections.size() ; i++) 49 for(int i=0; i< uninstallSections.size() ; i++)
73 { 50 {
74 m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO); 51 m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO);
75 installlog.beginGroup(uninstallSections.at(i)); 52 installlog.beginGroup(uninstallSections.at(i));
76 QStringList toDeleteList = installlog.allKeys(); 53 QStringList toDeleteList = installlog.allKeys();
77 QStringList dirList; 54 QStringList dirList;
78 55
79 // iterate over all entrys 56 // iterate over all entrys
80 for(int j =0; j < toDeleteList.size(); j++ ) 57 for(int j =0; j < toDeleteList.size(); j++ )
81 { 58 {
@@ -101,7 +78,7 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
101 78
102 installlog.endGroup(); 79 installlog.endGroup();
103 //installlog.removeGroup(uninstallSections.at(i)) 80 //installlog.removeGroup(uninstallSections.at(i))
104 } 81 }
105 uninstallSections.clear(); 82 uninstallSections.clear();
106 installlog.sync(); 83 installlog.sync();
107 m_dp->setProgressMax(1); 84 m_dp->setProgressMax(1);
@@ -121,5 +98,5 @@ QStringList Uninstaller::getAllSections()
121 98
122bool Uninstaller::uninstallPossible() 99bool Uninstaller::uninstallPossible()
123{ 100{
124 return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists(); 101 return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists();
125} 102}