summaryrefslogtreecommitdiffstats
path: root/tdefilereplace/tdefilereplacepart.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdefilereplace/tdefilereplacepart.cpp')
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index dc96db4..d4433b6 100644
--- a/tdefilereplace/tdefilereplacepart.cpp
+++ b/tdefilereplace/tdefilereplacepart.cpp
@@ -196,7 +196,7 @@ void TDEFileReplacePart::slotReplacingOperation()
if(m_option->m_recursive)
{
int filesNumber = 0;
- recursiveFileReplace(currentDirectory, filesNumber);
+ recursiveFileReplace(currentDirectory, filesNumber, 0);
}
else
{
@@ -967,10 +967,10 @@ void TDEFileReplacePart::fileReplace()
}
}
-void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int& filesNumber)
+void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int& filesNumber, int depth)
{
- //if m_stop == true then interrupts recursion
- if(m_stop)
+ // if m_stop == true or the max depth level is reached, then interrupt recursion
+ if (m_stop || (m_option->m_limitDepth && depth > m_option->m_maxDepth))
return;
else
{
@@ -1001,12 +1001,17 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int
m_view->displayScannedFiles(filesNumber);
- //if filePath is a directory then recursion
- if(qi.isDir())
- recursiveFileReplace(filePath, filesNumber);
+ // Replace recursively if "filePath" is a directory and we have not reached the max depth level
+ if (qi.isDir())
+ {
+ if (!m_option->m_limitDepth || depth < m_option->m_maxDepth)
+ {
+ recursiveFileReplace(filePath, filesNumber, depth+1);
+ }
+ }
else
{
- kapp->processEvents();
+ kapp->processEvents();
if(m_option->m_backup)
replaceAndBackup(d.canonicalPath(), fileName);
else