From: kawi Date: Fri, 2 Jan 2015 00:25:10 +0000 (+0100) Subject: ReDirTool corrections X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=77afc85418af9dbc62d273d6ba0fbb68e8195e32;p=crepublib ReDirTool corrections --- diff --git a/os/DirTools.hpp b/os/DirTools.hpp index f714b94..9f210b8 100644 --- a/os/DirTools.hpp +++ b/os/DirTools.hpp @@ -40,8 +40,13 @@ public: const ReStringList& calculate(const char* base, int depth, void (*format)(const ReDirStatisticData& data, ReDirStatistic& parent, ReByteBuffer& line) = formatLikeDu); + void setTraceInterval(int interval){ + m_traceInterval = interval; + } private: ReStringList m_list; + int m_traceInterval; + time_t m_lastTrace; }; diff --git a/os/ReDirTools.cpp b/os/ReDirTools.cpp index de84c42..f395fa6 100644 --- a/os/ReDirTools.cpp +++ b/os/ReDirTools.cpp @@ -70,7 +70,9 @@ ReDirStatisticData& ReDirStatisticData::add(const ReDirStatisticData& source){ * Constructor. */ ReDirStatistic::ReDirStatistic(int deltaList, int deltaBuffer) : - m_list(deltaList, deltaBuffer) + m_list(deltaList, deltaBuffer), + m_traceInterval(0), + m_lastTrace(0) { } /** @@ -103,6 +105,7 @@ const ReStringList& ReDirStatistic::calculate(const char* base, int level, ReDirStatisticData* current = dataStack[0]; current->m_path.set(base, -1); ReByteBuffer line; + int traceCount = 0; while( (entry = traverser.rawNextFile(currentDepth))){ if (currentDepth <= level && ! entry->m_path.equals(current->m_path)){ if (currentDepth <= topOfStack){ @@ -140,6 +143,14 @@ const ReStringList& ReDirStatistic::calculate(const char* base, int level, } else { current->m_sizes += entry->fileSize(); current->m_files++; + if (++traceCount % 100 == 0 && m_traceInterval > 0){ + time_t now = time(NULL); + int diff = int(now - m_lastTrace); + if (diff >= m_traceInterval){ + fprintf(stderr, "%s\n", current->m_path.str()); + m_lastTrace = now; + } + } } } // close all dirs with parents: