diff options
Diffstat (limited to 'rbutil/rbutilqt/utils.cpp')
-rw-r--r-- | rbutil/rbutilqt/utils.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/utils.cpp b/rbutil/rbutilqt/utils.cpp new file mode 100644 index 0000000000..c7c8371274 --- /dev/null +++ b/rbutil/rbutilqt/utils.cpp | |||
@@ -0,0 +1,45 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id$ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "utils.h" | ||
21 | |||
22 | #include <QDir> | ||
23 | |||
24 | // recursive function to delete a dir with files | ||
25 | bool recRmdir( const QString &dirName ) | ||
26 | { | ||
27 | QString dirN = dirName; | ||
28 | QDir dir(dirN); | ||
29 | QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory | ||
30 | QFileInfo fileInfo; | ||
31 | QString curItem, lstAt; | ||
32 | for(int i = 0; i < list.size(); i++){ // loop through all items of list | ||
33 | QString name = list.at(i); | ||
34 | if(!(name == ".") && !(name == "..")){ | ||
35 | curItem = dirN + "/" + name; | ||
36 | fileInfo.setFile(curItem); | ||
37 | if(fileInfo.isDir()) // is directory | ||
38 | recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory | ||
39 | else // is file | ||
40 | QFile::remove(curItem); // ok, delete file | ||
41 | } | ||
42 | } | ||
43 | dir.cdUp(); | ||
44 | return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull | ||
45 | } | ||