1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 // recursive function to delete a dir with files
25 bool recRmdir( const QString
&dirName
)
27 QString dirN
= dirName
;
29 // make list of entries in directory
30 QStringList list
= dir
.entryList(QDir::AllEntries
| QDir::NoDotAndDotDot
);
32 QString curItem
, lstAt
;
33 for(int i
= 0; i
< list
.size(); i
++){ // loop through all items of list
34 QString name
= list
.at(i
);
35 curItem
= dirN
+ "/" + name
;
36 fileInfo
.setFile(curItem
);
37 if(fileInfo
.isDir()) // is directory
38 recRmdir(curItem
); // call recRmdir() recursively for deleting subdirectory
40 QFile::remove(curItem
); // ok, delete file
43 return dir
.rmdir(dirN
); // delete empty dir and return if (now empty) dir-removing was successfull