summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/base/utils.cpp')
-rw-r--r--rbutil/rbutilqt/base/utils.cpp63
1 files changed, 11 insertions, 52 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index 623dfebe2f..767b3c1c52 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -18,6 +18,7 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include "utils.h" 20#include "utils.h"
21#include "rockboxinfo.h"
21#include "system.h" 22#include "system.h"
22#include "rbsettings.h" 23#include "rbsettings.h"
23#include "systeminfo.h" 24#include "systeminfo.h"
@@ -41,7 +42,7 @@
41#endif 42#endif
42 43
43// recursive function to delete a dir with files 44// recursive function to delete a dir with files
44bool recRmdir( const QString &dirName ) 45bool Utils::recursiveRmdir( const QString &dirName )
45{ 46{
46 QString dirN = dirName; 47 QString dirN = dirName;
47 QDir dir(dirN); 48 QDir dir(dirN);
@@ -54,19 +55,21 @@ bool recRmdir( const QString &dirName )
54 curItem = dirN + "/" + name; 55 curItem = dirN + "/" + name;
55 fileInfo.setFile(curItem); 56 fileInfo.setFile(curItem);
56 if(fileInfo.isDir()) // is directory 57 if(fileInfo.isDir()) // is directory
57 recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory 58 recursiveRmdir(curItem); // call recRmdir() recursively for
59 // deleting subdirectory
58 else // is file 60 else // is file
59 QFile::remove(curItem); // ok, delete file 61 QFile::remove(curItem); // ok, delete file
60 } 62 }
61 dir.cdUp(); 63 dir.cdUp();
62 return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull 64 return dir.rmdir(dirN); // delete empty dir and return if (now empty)
65 // dir-removing was successfull
63} 66}
64 67
65 68
66//! @brief resolves the given path, ignoring case. 69//! @brief resolves the given path, ignoring case.
67//! @param path absolute path to resolve. 70//! @param path absolute path to resolve.
68//! @return returns exact casing of path, empty string if path not found. 71//! @return returns exact casing of path, empty string if path not found.
69QString resolvePathCase(QString path) 72QString Utils::resolvePathCase(QString path)
70{ 73{
71 QStringList elems; 74 QStringList elems;
72 QString realpath; 75 QString realpath;
@@ -110,7 +113,7 @@ QString resolvePathCase(QString path)
110//! @brief figure the free disk space on a filesystem 113//! @brief figure the free disk space on a filesystem
111//! @param path path on the filesystem to check 114//! @param path path on the filesystem to check
112//! @return size in bytes 115//! @return size in bytes
113qulonglong filesystemFree(QString path) 116qulonglong Utils::filesystemFree(QString path)
114{ 117{
115 qlonglong size = 0; 118 qlonglong size = 0;
116#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) 119#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
@@ -135,7 +138,7 @@ qulonglong filesystemFree(QString path)
135} 138}
136 139
137//! \brief searches for a Executable in the Environement Path 140//! \brief searches for a Executable in the Environement Path
138QString findExecutable(QString name) 141QString Utils::findExecutable(QString name)
139{ 142{
140 QString exepath; 143 QString exepath;
141 //try autodetect tts 144 //try autodetect tts
@@ -167,7 +170,7 @@ QString findExecutable(QString name)
167 * @param permission if it should check for permission 170 * @param permission if it should check for permission
168 * @return string with error messages if problems occurred, empty strings if none. 171 * @return string with error messages if problems occurred, empty strings if none.
169 */ 172 */
170QString check(bool permission) 173QString Utils::checkEnvironment(bool permission)
171{ 174{
172 QString text = ""; 175 QString text = "";
173 176
@@ -201,47 +204,3 @@ QString check(bool permission)
201 return text; 204 return text;
202} 205}
203 206
204
205RockboxInfo::RockboxInfo(QString mountpoint)
206{
207 qDebug() << "[RockboxInfo] trying to find rockbox-info at" << mountpoint;
208 QFile file(mountpoint + "/.rockbox/rockbox-info.txt");
209 m_success = false;
210 if(!file.exists())
211 return;
212
213 if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
214 return;
215
216 // read file contents
217 while (!file.atEnd())
218 {
219 QString line = file.readLine();
220
221 if(line.contains("Version:"))
222 {
223 m_version = line.remove("Version:").trimmed();
224 }
225 else if(line.contains("Target: "))
226 {
227 m_target = line.remove("Target: ").trimmed();
228 }
229 else if(line.contains("Features:"))
230 {
231 m_features = line.remove("Features:").trimmed();
232 }
233 else if(line.contains("Target id:"))
234 {
235 m_targetid = line.remove("Target id:").trimmed();
236 }
237 else if(line.contains("Memory:"))
238 {
239 m_ram = line.remove("Memory:").trimmed().toInt();
240 }
241 }
242
243 file.close();
244 m_success = true;
245 return;
246}
247