236f28babd6b99899369cb78d2cc6a7755aad398
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 ****************************************************************************/
27 // recursive function to delete a dir with files
28 bool recRmdir( const QString
&dirName
)
30 QString dirN
= dirName
;
32 // make list of entries in directory
33 QStringList list
= dir
.entryList(QDir::AllEntries
| QDir::NoDotAndDotDot
);
35 QString curItem
, lstAt
;
36 for(int i
= 0; i
< list
.size(); i
++){ // loop through all items of list
37 QString name
= list
.at(i
);
38 curItem
= dirN
+ "/" + name
;
39 fileInfo
.setFile(curItem
);
40 if(fileInfo
.isDir()) // is directory
41 recRmdir(curItem
); // call recRmdir() recursively for deleting subdirectory
43 QFile::remove(curItem
); // ok, delete file
46 return dir
.rmdir(dirN
); // delete empty dir and return if (now empty) dir-removing was successfull
50 //! @brief resolves the given path, ignoring case.
51 //! @param path absolute path to resolve.
52 //! @return returns exact casing of path, empty string if path not found.
53 QString
resolvePathCase(QString path
)
58 elems
= path
.split("/", QString::SkipEmptyParts
);
60 #if defined(Q_OS_WIN32)
61 // on windows we must make sure to start with the first entry (i.e. the
62 // drive letter) instead of a single / to make resolving work.
64 realpath
= elems
.at(0) + "/";
70 for(int i
= start
; i
< elems
.size(); i
++) {
72 = QDir(realpath
).entryList(QDir::AllEntries
|QDir::Hidden
|QDir::System
);
73 if(direlems
.contains(elems
.at(i
), Qt::CaseInsensitive
)) {
74 // need to filter using QRegExp as QStringList::filter(QString)
75 // matches any substring
76 QString expr
= QString("^" + elems
.at(i
) + "$");
77 QRegExp rx
= QRegExp(expr
, Qt::CaseInsensitive
);
78 QStringList a
= direlems
.filter(rx
);
82 if(!realpath
.endsWith("/"))
89 qDebug() << __func__
<< path
<< "->" << realpath
;