Index: kstandarddirs.cpp
===================================================================
--- kstandarddirs.cpp	(Revision 510255)
+++ kstandarddirs.cpp	(Arbeitskopie)
@@ -1674,3 +1674,71 @@
     QString file = filename.mid(slash);
     return inst->dirs()->saveLocation(type, dir, createDir) + file;
 }
+
+
+// Auxiliary recursive function for removeDirs
+static bool rmtree( const QCString& name )
+{
+    kdDebug() << "Checking directory for remove " << name << endl;
+    KDE_struct_stat st;
+    if ( KDE_lstat( name.data(), &st ) == -1 ) // Do not dereference symlink!
+        return false;
+    if ( S_ISDIR( st.st_mode ) )
+    {
+        // This is a directory, so process it
+        kdDebug() << "File " << name << " is DIRECTORY!" << endl;
+        struct dirent* ep;
+        DIR* dp = ::opendir( name.data() );
+        if ( !dp )
+            return false;
+        while ( ( ep = ::readdir( dp ) ) )
+        {
+            kdDebug() << "CHECKING " << name << "/" << ep->d_name << endl;
+            if ( !qstrcmp( ep->d_name, "." ) || !qstrcmp( ep->d_name, ".." ) )
+                continue;
+            QCString newName( name );
+            newName += "/"; // Careful: do not add '/' instead or you get problems with Qt3.
+            newName += ep->d_name;
+            /*
+             * Be defensive and close the directory.
+             *
+             * Potential problems:
+             * - opendir/readdir/closedir is not re-entrant
+             * - an unlink invalidates a opendir/readdir/closedir
+             * - limited number of file descriptors for opendir/readdir/closedir
+             */
+            if ( ::closedir( dp ) )
+                return false;
+            // Recurse!
+            kdDebug() << "RECURSE: " << newName << endl;
+            if ( ! rmtree( newName ) )
+                return false;
+            // We have to re-open the directory before continuing
+            dp = ::opendir( name.data() );
+            if ( !dp )
+                return false;
+        }
+        if ( ::closedir( dp ) )
+            return false;
+        kdDebug() << "RMDIR dir " << name << endl;
+        return ! ::rmdir( name );
+    }
+    else
+    {
+         // This is a non-directory file, so remove it
+         kdDebug() << "UNLINKING file " << name << endl;
+         return ! ::unlink( name );
+    }
+}
+
+bool KStandardDirs::removeDir( const QString& path )
+{
+    kdDebug() << k_funcinfo << " " << path << endl;
+    if ( !QFile::exists( path ) )
+        return true; // The goal is that there is no directory
+
+    const QCString cstr( QFile::encodeName( path ) );
+    return rmtree( cstr );
+}
+
+
Index: ktempdir.cpp
===================================================================
--- ktempdir.cpp	(Revision 510255)
+++ ktempdir.cpp	(Arbeitskopie)
@@ -136,12 +136,10 @@
 KTempDir::unlink()
 {
    if (!bExisting) return;
-   QString rmstr("/bin/rm -rf ");
-   rmstr += KProcess::quote(mTmpName);
-   ::system( QFile::encodeName(rmstr) );
-
+   if (KStandardDirs::removeDir(mTmpName))
+      mError=0;
+   else
+      mError=errno;
    bExisting=false;
-   mError=0;
 }
 
-
Index: kstandarddirs.h
===================================================================
--- kstandarddirs.h	(Revision 510255)
+++ kstandarddirs.h	(Arbeitskopie)
@@ -605,6 +605,28 @@
 	 */
 	static QString realFilePath(const QString &filename);
 
+	/**
+	 * @brief Remove a directory and all its contents
+         *
+         * Remove recursively a directory, even if it is not empty
+         * or contains other directories.
+         *
+         * However the function works too when the @p path given
+         * is a non-directory file. In that case it simply remove that file.
+         *
+         * The function stops on the first error.
+         *
+         * @note This function is more meant for removing a directory
+         * not created by the user. For user-created directories,
+         * using KIO::NetAccess::del is recommended instead,
+         * especially as it has user feedback for long operations.
+         *
+	 * @param path Path of the directory to delete
+	 * @return true if successful, otherwise false 
+         * (Use errno for more details about the error.)
+	 * @since 3.5.2
+	 */
+        static bool removeDir( const QString& path );
  private:
 
 	QStringList prefixes;
