From: Hamatoma Date: Fri, 6 Feb 2015 23:54:43 +0000 (+0100) Subject: ReDirStatistics works X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=489c8967f5794e9b7b3e782ee4228c1914f999d1;p=crepublib ReDirStatistics works --- diff --git a/base/ReByteBuffer.hpp b/base/ReByteBuffer.hpp index 9dcc9f9..dcf1f01 100644 --- a/base/ReByteBuffer.hpp +++ b/base/ReByteBuffer.hpp @@ -10,7 +10,7 @@ #ifndef REBYTEBUFFER_H_ #define REBYTEBUFFER_H_ -#define PRIMARY_BUFFER_SIZE 512 +#define PRIMARY_BUFFER_SIZE 513 /** @brief An efficient dynamic memory buffer. * diff --git a/base/ReSeqArray.cpp b/base/ReSeqArray.cpp index efe1f8f..4b66e3f 100644 --- a/base/ReSeqArray.cpp +++ b/base/ReSeqArray.cpp @@ -462,13 +462,15 @@ void ReSeqArray::set(Index index, const Byte* source, indexContent = m_content.length(); m_content.append(source, sourceLength); } - printf("vor:\n%s\n", ReByteBuffer("") +/* printf("vor:\n%s\n", ReByteBuffer("") .appendHexDump(m_list.str(), m_entrySize*(1+index), 0, m_entrySize*2, "%4d: ", false, m_entrySize, m_entrySize).str()); + */ setSequence(seq, indexContent, sourceLength, tag); - printf("dann:\n%s\n", ReByteBuffer("") + /*printf("dann:\n%s\n", ReByteBuffer("") .appendHexDump(m_list.str(), m_entrySize*(1+index), 0, m_entrySize*2, "%4d: ", false, m_entrySize, m_entrySize).str()); + */ } } diff --git a/cunit/cuReByteBuffer.cpp b/cunit/cuReByteBuffer.cpp index 4823b2f..63b8171 100644 --- a/cunit/cuReByteBuffer.cpp +++ b/cunit/cuReByteBuffer.cpp @@ -15,6 +15,7 @@ public: } private: void run(){ + testEnsureSize2(); testHexDump(); testFill(); testAppendMilliSec(); @@ -37,6 +38,14 @@ private: testSplice(); testReplace(); } + void testEnsureSize2(){ + ReByteBuffer buffer; + buffer.setLength(PRIMARY_BUFFER_SIZE - 1); + buffer.fill('x', PRIMARY_BUFFER_SIZE - 1); + checkEqu(PRIMARY_BUFFER_SIZE - 1, (int) buffer.capacity()); + buffer.ensureSize(PRIMARY_BUFFER_SIZE); + checkEqu(PRIMARY_BUFFER_SIZE*2 - 1, (int) buffer.capacity()); + } void testHexDump(){ ReByteBuffer buf; /* appendHexDump(const char* data, size_t length, int offset = 0, int bytePerLine = 16, @@ -56,10 +65,8 @@ private: " 28: 36373839 783132336789x123\n" " 36: 343536 456 \n", buf.str()); buf.setLength(0).appendHexDump("abcdefghijk", -1, 0, 8, "%3d: ", true, 2, 4); - printf("%s", buf.str()); - checkEqu(" 20: 090ac3bc 32333435....2345\n" - " 28: 36373839 783132336789x123\n" - " 36: 343536 456 \n", buf.str()); + checkEqu(" 0: 6162 6364 6566 6768 | abcd efgh\n" + " 8: 696a 6b | ijk \n", buf.str()); } void testFill(){ ReByteBuffer buf; @@ -271,10 +278,10 @@ private: checkEqu("123", buffer.buffer()); checkEqu(3u, buffer.length()); - buffer.setLengthAndFillOut(511, 'y'); - buffer.setLengthAndFillOut(512, 'z'); - checkEqu("yyz", buffer.buffer() + 509); - checkEqu(521u, buffer.capacity()); + buffer.setLengthAndFillOut(PRIMARY_BUFFER_SIZE - 1, 'y'); + buffer.setLengthAndFillOut(PRIMARY_BUFFER_SIZE, 'z'); + checkEqu("yyz", buffer.buffer() + PRIMARY_BUFFER_SIZE - 3); + checkEqu(PRIMARY_BUFFER_SIZE + 10 - 1, (int) buffer.capacity()); ReByteBuffer buffer2; buffer2.set("xyz", -1); diff --git a/cunit/cuReSeqArray.cpp b/cunit/cuReSeqArray.cpp index 11d8901..20bda85 100644 --- a/cunit/cuReSeqArray.cpp +++ b/cunit/cuReSeqArray.cpp @@ -196,7 +196,7 @@ private: ReSeqArray list; ReByteBuffer value; ReSeqArray::Tag tag = 0; - + list.setSizes(8, 4); list.add(-1, "xxx", -1, ReSeqArray::Tag(1l) << 31); checkT(list.get(0, value, &tag)); checkEqu(1ll << 31, tag); diff --git a/cunit/testall.cpp b/cunit/testall.cpp index 8960425..f9ca28a 100644 --- a/cunit/testall.cpp +++ b/cunit/testall.cpp @@ -13,8 +13,8 @@ #endif void testBase(){ - extern void testReByteBuffer(); - testReByteBuffer(); + extern void testReSeqArray(void); + testReSeqArray(); extern void testReTestUnit(); //testReTestUnit(); @@ -73,12 +73,12 @@ void testMath(){ void testAll(){ try { - testString(); - testOs(); + testBase(); - testMath(); testString(); + testMath(); + testOs(); } catch (ReException e){ fprintf(stderr, "testBase.cpp: unexpected exception: %s\n", e.getMessage()); } diff --git a/os/ReDirTools.cpp b/os/ReDirTools.cpp index 11d9bce..193b94c 100644 --- a/os/ReDirTools.cpp +++ b/os/ReDirTools.cpp @@ -531,6 +531,9 @@ void ReDirOptions::optimizePathPattern(ReByteBuffer& buffer){ * @param filter OUT: the filter to set */ void ReDirOptions::setFilterFromProgramArgs(ReDirEntryFilter_t& filter){ +{ ReByteBuffer buf; +const char* ptr = m_programArgs.getString("pathpattern", buf); +} ReByteBuffer buffer; if (m_programArgs.getString("younger", buffer)[0] != '\0') filter.m_maxAge = checkDate(buffer.str()); @@ -787,12 +790,11 @@ void ReDirStatistic::run(int argc, const char* argv[]){ if (ReStringUtils::lengthOfUnsigned(arg1, -1, (unsigned *) &depth) == 0) m_programArgs.help("depth is not an integer", false, stdout); } - ReDirStatistic statistic; void (*proc) (const ReDirStatisticData& data, ReDirStatistic& parent, ReByteBuffer& line) = &formatWithSizeFilesAndDirs; if (m_programArgs.getBool("kbyte")) proc = &formatLikeDu; - const ReStringList& list = statistic.calculate(m_programArgs.getArg(0), depth, proc); + const ReStringList& list = calculate(m_programArgs.getArg(0), depth, proc); ReByteBuffer buffer; for (size_t ix = 0; ix < list.count(); ix++){ buffer.set(list.strOf(ix), list.strLengthOf(ix)); diff --git a/os/ReTraverser.cpp b/os/ReTraverser.cpp index d3f13bc..c934cb0 100644 --- a/os/ReTraverser.cpp +++ b/os/ReTraverser.cpp @@ -600,7 +600,7 @@ bool ReTraverser::initEntry(const ReByteBuffer& parent, const char* node, int le void ReTraverser::setPropertiesFromFilter(ReDirEntryFilter_t* filter){ m_minLevel = filter->m_minDepth; m_maxLevel = filter->m_maxDepth; - m_dirPatterns = filter->m_pathPatterns; + setDirPattern(filter->m_pathPatterns); } /** diff --git a/os/ReTraverser.hpp b/os/ReTraverser.hpp index b37766d..1013d29 100644 --- a/os/ReTraverser.hpp +++ b/os/ReTraverser.hpp @@ -156,7 +156,7 @@ public: * @param pattern pattern list for the subdirs to be entered */ void setDirPattern(RePatternList* pattern) - { m_dirPatterns = pattern; } + { m_dirPatterns = pattern; m_dirPatterns->setIgnoreCase(true); } /** Sets the maximal depth. * @param value the value to set */