summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_unix.cpp
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-09-03 07:37:43 (GMT)
committerThomas Zander <t.zander@nokia.com>2010-09-03 07:37:43 (GMT)
commit5b76ea63f5dba0a6b427d9d4dbcb7be6d7afeeec (patch)
treedea856ab744d35dd0ae40b7d707696a3db3f41b0 /src/corelib/io/qfilesystemengine_unix.cpp
parente6747da757b4daba1fc17db9902a9c39b426455f (diff)
downloadQt-5b76ea63f5dba0a6b427d9d4dbcb7be6d7afeeec.zip
Qt-5b76ea63f5dba0a6b427d9d4dbcb7be6d7afeeec.tar.gz
Qt-5b76ea63f5dba0a6b427d9d4dbcb7be6d7afeeec.tar.bz2
Move rmdir code to createDirectory for unix'
migrate the QFSFileEngine::rmdir code to QFileSystemEngine::removeDirectory and make the former call the latter. Reviewed-by: João Abecasis
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 469abfe..7c72782 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -202,7 +202,27 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
//static
bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
{
- return false; // TODO implement;
+ if (removeEmptyParents) {
+ QString dirName = QDir::cleanPath(entry.filePath());
+#if defined(Q_OS_SYMBIAN)
+ dirName = QDir::toNativeSeparators(dirName);
+#endif
+ for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
+ QByteArray chunk = QFile::encodeName(dirName.left(slash));
+ QT_STATBUF st;
+ if (QT_STAT(chunk, &st) != -1) {
+ if ((st.st_mode & S_IFMT) != S_IFDIR)
+ return false;
+ if (::rmdir(chunk) != 0)
+ return oldslash != 0;
+ } else {
+ return false;
+ }
+ slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
+ }
+ return true;
+ }
+ return rmdir(QFile::encodeName(entry.filePath())) == 0;
}
//static