Pointer cosmetic changes
[Rockbox.git] / rbutil / rbutilqt / utils.cpp
blob7458223e7338ad918cd5911ac316cbc41fb350ef
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id$
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 ****************************************************************************/
20 #include "utils.h"
22 #include <QDir>
24 // recursive function to delete a dir with files
25 bool recRmdir( const QString &dirName )
27 QString dirN = dirName;
28 QDir dir(dirN);
29 // make list of entries in directory
30 QStringList list = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
31 QFileInfo fileInfo;
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
39 else // is file
40 QFile::remove(curItem); // ok, delete file
42 dir.cdUp();
43 return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull