]> gitweb.hamatoma.de Git - crepublib/commitdiff
Refactoring, license
authorhama <hama@siduction.net>
Wed, 21 Jan 2015 22:57:27 +0000 (23:57 +0100)
committerhama <hama@siduction.net>
Wed, 21 Jan 2015 22:57:27 +0000 (23:57 +0100)
65 files changed:
base/ReByteBuffer.cpp
base/ReByteBuffer.hpp
base/ReCString.cpp
base/ReCString.hpp
base/ReConfigFile.cpp
base/ReConfigFile.hpp
base/ReDirectory.cpp
base/ReDirectory.hpp
base/ReException.cpp
base/ReException.hpp
base/ReHashList.cpp
base/ReHashList.hpp
base/ReI18N.cpp
base/ReI18N.hpp
base/ReLogger.cpp
base/ReLogger.hpp
base/ReProgramArgs.cpp
base/ReProgramArgs.hpp
base/ReSeqArray.cpp
base/ReSeqArray.hpp
base/ReStringList.cpp
base/ReStringList.hpp
base/ReStringUtils.cpp
base/ReStringUtils.hpp
base/ReTestUnit.cpp
base/ReTestUnit.hpp
base/ReVarArgs.cpp
base/ReVarArgs.hpp
base/baselocations.hpp
base/rebase.hpp
base/remath.hpp
base/renet.hpp
base/restring.hpp
cunit/basetest.cpp
cunit/cuReByteBuffer.cpp
cunit/cuReCString.cpp
cunit/cuReDirectory.cpp
cunit/cuReException.cpp
cunit/cuReHashList.cpp
cunit/cuReI18N.cpp
cunit/cuReLogger.cpp
cunit/cuReMatcher.cpp
cunit/cuReProgramArgs.cpp
cunit/cuReRandomizer.cpp
cunit/cuReSeqArray.cpp
cunit/cuReStringList.cpp
cunit/cuReStringUtils.cpp
cunit/cuReTest.cpp
cunit/cuReTraverser.cpp
cunit/cuReVarArgs.cpp
cunit/cuReconfig.cpp
cunit/testall.cpp
math/ReObfuscator.cpp
math/ReObfuscator.hpp
math/ReRandomizer.cpp
math/ReRandomizer.hpp
math/remath.hpp
os/ReDirTools.cpp
os/ReDirTools.hpp
os/ReTraverser.cpp
os/ReTraverser.hpp
os/reos.hpp
string/ReMatcher.cpp
string/ReMatcher.hpp
string/restring.hpp

index 8c72be5f945c60388d6665deb8afd70c880a6b63..514f2bdcaa12bbfff2296bfea1d306eee3b914e1 100644 (file)
@@ -1,7 +1,10 @@
 /*
  * ReByteBuffer.cpp
  *
- *  Created on: 06.05.2010
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index e4df448bd46b6596b2f28fe0fe60ed06659f7cec..32545ce6871daf9ff9603c2257a6513d1b175504 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * @file ReByteBuffer.hpp
+ * ReByteBuffer.hpp
  *
- *  Created on: 06.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REBYTEBUFFER_H_
index 7160bca7be1227496c674d9ed64bc6dcb9f0650e..1d10205ffc7dc7cd5a1f255cdfbc2cc98ebee30c 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReString.cpp
+ * ReCString.cpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index b142431b624b3846895dd187177e0c16a9a7ad46..3088ad2bfe8daa2eea23c0ae5821915bafabd55f 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReString.h
+ * ReCString.hpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RESTRING_H_
index ec56b0624f9a232ee643ed3654730f3c7d800a14..a7969a20d40205e1381cf8c6abbf6fc947a8cd32 100644 (file)
@@ -1,7 +1,10 @@
 /*
- * @file ReConfigFile.cpp
+ * ReConfigFile.cpp
  *
- * @brief Configuration file handling for *.ini files.
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index c8ac06378eed082930f94b078ffb08c43479fa5e..507ac170209487d61df776b76133c8e2140c6e1c 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReConfigFile.h
  *
- *  Created on: 18.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RECONFIGFILE_H_
index 80adc7caf13ab592b39a408bfa389b6c8e59a435..784f0375f133c8461b9d1a440bfe8734517250b4 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReFileUtils.cpp
+ * ReDirectory.cpp
  *
- *  Created on: 16.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
@@ -80,13 +82,13 @@ void ReDirectory::setDir(const char* path){
        m_dir = opendir(path);
        m_valid = m_dir != NULL;
        if (m_valid){
-               if (m_path.at(m_path.length() - 1) != ReStringUtils::pathSeparator())
-                       m_path.append(ReStringUtils::pathSeparatorStr(), 1);
+               if (m_path.at(m_path.length() - 1) != OS_SEPARATOR_CHAR)
+                       m_path.append(OS_SEPARATOR, 1);
        }
 #elif defined __WIN32__
     struct stat info;
     ReByteBuffer thePath(m_path);
-    if (m_path.endsWith(ReStringUtils::pathSeparatorStr()))
+    if (m_path.endsWith(OS_SEPARATOR))
         thePath.setLength(thePath.length() - 1);
     m_valid = stat(thePath.str(), &info) == 0 && S_ISDIR(info.st_mode);
 #endif
@@ -149,7 +151,7 @@ bool ReDirectory::findFirst(const char* pattern, bool isRegExpr){
                }
 #elif defined __WIN32__
         ReByteBuffer full(m_path);
-        full.append(ReStringUtils::pathSeparatorStr(), -1).append(pattern, -1);
+        full.append(OS_SEPARATOR, -1).append(pattern, -1);
         m_handle = FindFirstFileA(full.str(), &m_data);
         rc = m_handle != INVALID_HANDLE_VALUE;
 #endif
index 81634b10df6444fb6fba4d27a33a55e1346ab538..f51df7ccda4f6451224ccfea4421813af44f2ceb 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReFileUtils.h
+ * ReDirectory.hpp
  *
- *  Created on: 16.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REFILEFINDER_H_
index 4f2da16d28dd402c63fc8b64d5f0f465214b8b4d..e2a2bfbd6993d769aa199976bebca59597369a6d 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReException.cpp
  *
- *  Created on: 07.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index 173b8eb2eb331a31ecc531a53637c92c3fe383d4..ef4a12a58e28bea93711ee1a43b1aedcc5fc656d 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReException.h
+ * ReException.hpp
  *
- *  Created on: 07.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REEXCEPTION_H_
index cc0e6b8484effaa605e36ff26c3708cf4f0680d6..d264baf0d9937e361febb154671322b8ef065f99 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReStringList.cpp
+ * ReHashList.cpp
  *
- *  Created on: 18.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index 1def1442fc666ff6e5e2d5632cafa251280fe9cf..3c0a249cbdac46b268f7a9be2325770a41cc2491 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReStringList.h
+ * ReHashList.hpp
  *
- *  Created on: 18.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REHASHLIST_H_
index 993634283a82651d048b91a619c8670bd38fcbf7..ac79491a99dcc53cc73ba4ce2866bf0df9c7bb5c 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReI18N.cpp
  *
- *  Created on: 22.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index 070d00e2d20de4255c6d745f61ba84313649922b..81c1038e142f27fd7ff0b794d18137efe73a62cc 100644 (file)
@@ -1,7 +1,10 @@
 /*
- * ReI18N.h
+ * ReI18N.hpp
  *
- *  Created on: 22.05.2010
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  *      Author: wk
  */
 
index 37488ef377cdda9a2f2d12646c6f8d6de9f49442..f222c3051758bfcd9a9e62111c93019c4d3879a6 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReLogger.cpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index 07a317871e4fa791451357580686eb3484c5be1f..89471647ee68a515e0ebf5680b1a45f8724f5382 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReLogger.h
+ * ReLogger.hpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RELOGGER_H_
index 9329deecd42c3ff7c3f52d6f840791e4af3e6b8b..537579c8bdf92244754646b4c3e621ed769af2c5 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReProgramArgs.cpp
  *
- *  Created on: 25.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index dbb1b108a796c3b2f5b92fd8aabc97bb437b5f56..954eec4c4fbf6a6cb905bf5aee04a9c911d1583b 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReProgramArgs.h
+ * ReProgramArgs.hpp
  *
- *  Created on: 25.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REPROGRAMARGS_H_
index 66fe1ecfe11fee4a2f8a59eca012b12845dc8d10..36079d1011d47aa9799e79a923f51e463c66ebc8 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReSeqArray.cpp
  *
- *  Created on: 19.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index fa460f5cc44485fbe01b3a281ceb3f000c88ccc0..9507583ed42daf8bb6716fd76a8e090de24d20b1 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReSeqArray.h
+ * ReSeqArray.hpp
  *
- *  Created on: 19.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RESEQLIST_H_
index f0bf879b324356961797f767740f90ed3b4fe7ed..ab0d5a8d6bf994d95644220ec7401c590c76e0c8 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReStringList.cpp
  *
- *  Created on: 20.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index 7f5efa883a6faa6056db90220f44ee6e5081c6f0..08b1d8276193d261cd9f7b79d108bbe13c29cbe2 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReStringList.h
+ * ReStringList.hpp
  *
- *  Created on: 20.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RESTRINGLIST_H_
index 544c02246f2e991629c55ce2ecb273a3d406680e..d24bb9481451a548b82f21caa462251374681c59 100644 (file)
@@ -1,52 +1,16 @@
 /*
  * ReStringUtils.cpp
  *
- *  Created on: 16.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
 
-#if defined __linux__
-char ReStringUtils::slash = '/';
-const char* ReStringUtils::slashStr = "/";
-#elif defined __WIN32__
-char ReStringUtils::slash = '\\';
-const char* ReStringUtils::slashStr = "\\";
-#endif
 const char ReStringUtils::AUTO_SEPARATOR = '\0';
 
-
-/** @brief Initializes the os specific path separator (char and string).
- *
- * @return The path separator: '/' under unix and '\\' under windows.
- */
-char ReStringUtils::initPathSeparator(){
-       slashStr = NULL;
-       if (getenv("PATH") != NULL){
-               if (strchr(getenv("PATH"), '\\') != NULL)
-                       slashStr = "\\";
-               else if (strchr(getenv("PATH"), '/') == NULL)
-                       slashStr = "/";
-       }
-       if (slashStr != NULL && getenv("TMP") != NULL){
-               if (strchr(getenv("TMP"), '\\') != NULL)
-                       slashStr = "\\";
-               else if (strchr(getenv("TMP"), '/') == NULL)
-                       slashStr = "/";
-       }
-       if (slashStr == NULL && getenv("TEMP") != NULL){
-               if (strchr(getenv("TEMP"), '\\') != NULL)
-                       slashStr = "\\";
-               else if (strchr(getenv("TMP"), '/') == NULL)
-                       slashStr = "/";
-       }
-       if (slashStr == NULL)
-               slashStr = "/";
-       return slashStr[0];
-}
-
-
 /** @brief Splits a filename into its parts.
  *
  * Example: file:/etc/samba/smb.conf
@@ -75,7 +39,7 @@ char ReStringUtils::initPathSeparator(){
  */
 void ReStringUtils::splitPath(const char* fullname,
        ReByteBuffer* protocol, ReByteBuffer* path, ReByteBuffer* name, ReByteBuffer* ext){
-    const char currentSlash = strchr(fullname, '/') != NULL ? '/' : slash;
+    const char currentSlash = strchr(fullname, '/') != NULL ? '/' : OS_SEPARATOR_CHAR;
        const char* start = strchr(fullname, ':');
        if (protocol != NULL){
                protocol->setLength(0);
index 20b667aa1395953df8232f7fe79829d165ae478e..2c42f27c81f8fc86cd58af629c3bb2cb9ba3ec4e 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReStringUtils.h
+ * ReStringUtils.hpp
  *
- *  Created on: 16.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RESTRINGUTILS_H_
@@ -17,11 +19,6 @@ public:
        //@ If used in <code>isInList()</code> the first character of the list will be the separator.
        static const char AUTO_SEPARATOR;
 public:
-       static char initPathSeparator();
-       static char pathSeparator()
-       { return slash; }
-       static const char* pathSeparatorStr()
-       { return slashStr; }
        static void splitPath(const char* fullname,
                ReByteBuffer* protocol, ReByteBuffer* path, ReByteBuffer* name, ReByteBuffer* ext);
        static ReByteBuffer& joinPath(ReByteBuffer& result,
@@ -31,9 +28,6 @@ public:
        static int strnicmp(const char* string1, const char* string2, size_t length);
        static bool isInList(const char* phrase, const char* list,
                        bool ignoreCase = true, char separator = AUTO_SEPARATOR);
-private:
-       static char slash;
-       static const char* slashStr;
 };
 
 #endif /* RESTRINGUTILS_H_ */
index 232a104eafcf631066a0ac59cbf501bd43b2b538..af49e6a4345808cb0853d442c714c2833ddb5465 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReTestUnit.cpp
  *
- *  Created on: 04.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 #include "base/rebase.hpp"
 /** @brief Constructor.
@@ -219,10 +221,10 @@ void ReTestUnit::createTestDir(){
                        strcpy(name, "/tmp/");
                }
                char* ptr = name + strlen(name) - 1;
-               if (*ptr != ReStringUtils::pathSeparator())
-                       strcpy(ptr + 1, ReStringUtils::pathSeparatorStr());
+               if (*ptr != OS_SEPARATOR_CHAR)
+                       strcpy(ptr + 1, OS_SEPARATOR);
                strcat(ptr, "retestunit");
-               strcat(ptr, ReStringUtils::pathSeparatorStr());
+               strcat(ptr, OS_SEPARATOR);
                struct stat info;
        #ifdef __WIN32__
        #define ALLPERMS 0
@@ -249,12 +251,9 @@ void ReTestUnit::createTestDir(){
  * @return     a time usable for for runtime measurement
  */
 int ReTestUnit::milliSecSince(int64_t start){
-#if defined __linux__
+#if defined __linux__ || defined __WIN32__
        int64_t diff = clock() - start;
-       return diff * 1000 / CLOCKS_PER_SEC;
-#elif defined __WIN32__
-    int64_t diff = clock() - start;
-    return diff * 1000 / CLOCKS_PER_SEC;
+       return int(diff * 1000 / CLOCKS_PER_SEC);
 #else
 #      error "timer not defined"
 #endif
index d902ada5add63647993068146c92adb7199df2f7..87df8c4d6e7ef206d8b5e320fadc343f46f9a54f 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReTestUnit.h
+ * ReTestUnit.hpp
  *
- *  Created on: 04.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RETESTUNIT_H_
index 969da46cc49504920b6c7f81f07d6eea853275ad..77f24743a7c5bd020af82e51f3fb2ac352a6cda8 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReVarArgs.cpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 /**
  * <pre><strong>Example:</strong>
index 6239c4cb9ce42056fffb32ae5a8afc2b6ea50e2e..b20cf3d5c685bab97f0f5825e1bbc88b4091149c 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReVarArgs.h
+ * ReVarArgs.hpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REVARARGS_H_
index 86a839a18f93a9690f4210e84562155ac088feeb..da874a0359afedb00da6b654310b2242c53fbbeb 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * baselocations.hpp
  *
- *  Created on: 19.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef BASELOCATIONS_HPP_
index 8ad33c652485451f3289039c1551be29753eb676..6f327bb4a81960e4532bf7be58fc5c76d8492821 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * stdincludes.hpp
+ * rebase.hpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 #ifndef REBASE_HPP_
 #define REBASE_HPP_
@@ -36,11 +38,15 @@ typedef u_int64_t uint64_t;
 #      define _snprintf snprintf
 #      define _memcmp(t,s,n) memcmp(t,s,n)
 #      define _mkdir(path) mkdir(path, ALLPERMS)
+#      define OS_SEPARATOR_CHAR '/'
+#      define OS_SEPARATOR "/"
 #elif defined __WIN32__
 #      include <direct.h>
 #      include <windows.h>
 #      define _memcmp(t,s,n) memcmp(t,s,n)
 #      define lstat stat
+#      define OS_SEPARATOR_CHAR '\\'
+#      define OS_SEPARATOR "\\"
        typedef _int64 int64_t;
     typedef unsigned long long uint64_t;
     typedef unsigned char uint8_t;
index a7528d54daece20e9c0da9ef50e5995859785075..5ea7c50ea55b6b1fea6465fec2149eaa09f5c882 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * remath.hpp
  *
- *  Created on: 26.11.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REMATH_HPP_
index 4be9e2e70c4766f2c1e7423b8d52c4c66ca1ff92..a1e33cf6ad7e398dbe5a9fe4a6321971a15a0617 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * renet.hpp
  *
- *  Created on: 26.11.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RENET_HPP_
index 3cbd7cde541cea506d20f4d0164f1999f44750c0..82d9489c4e57fd787986f5223b5f2937cca01339 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * restring.hpp
  *
- *  Created on: 15.11.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RESTRING_HPP_
index 2a7d7edaee85402909147bcbee9bc3a44fef1f4d..75d669e0b9d2f32b9b5e327a97bd0fe1a49d8c38 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * stdtest.cpp
+ * basetest.cpp
  *
- *  Created on: 05.05.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 #include "base/rebase.hpp"
 #if defined RE_TESTUNIT
index 41481bdc85e176cac0743c952cb2014ca8283612..982d3fdf0312567ccfbf9db957614c7add7fb189 100644 (file)
@@ -1,7 +1,10 @@
 /*
  * cuReByteBuffer.cpp
  *
- *  Created on: 27.11.2010
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 #include "base/rebase.hpp"
 class TestReByteBuffer : public ReTestUnit {
index 931a2c40789c9e70f7452b69d50a293c1cdf1b10..0f4bb083de3e0e47b2593f132b1c13a6703cfe6e 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * cuReCString.cpp
  *
- *  Created on: 23.11.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 #include "base/rebase.hpp"
 #include "string/restring.hpp"
index 473e2598aa638c34edb1cdebf0a6f10ddd19d519..87f4df7f67117567c9dff0ca9e1fb7187b5ac121 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReDirectory.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReDirectory : public ReTestUnit {
index 0b5e3af2a471eeb61392246d5807f71d7f5c71bb..081ceae6a502155b7c1f83f7698118520c6a34e5 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReException.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReException : public ReTestUnit, public ReVarArgTrigger {
index fc21a667ca2c4916f8b936eadd2d5a470a955478..6d292957178b2b703c2e4b6866813ed0a8f3b477 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReHashList.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 #include "math/remath.hpp"
 
index 6f14ae28dcafc443dca21b4802508171a6b54a69..23a5bbac248b507ab7dac1d05ea85196a588dfa5 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReReI18N.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReI18N : public ReTestUnit {
index d9c4838d7abdd421f3cd5b4a8e6dad60df3e23c7..fff80a0cf6d00b3d51a0652fa818b25f04663435 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReLogger.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReLogger : public ReTestUnit {
index 36f7f1aaa33f3f65557beedd6a5c52524585f569..bff596592b9a134b5ce54a7a920c33c3b481a5e0 100644 (file)
@@ -1,9 +1,20 @@
 /*
  * cuReMatcher.cpp
  *
- *  Created on: 25.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
+/*
+ * cuReMatcher.hpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
+
 
 #include "base/rebase.hpp"
 #include "string/restring.hpp"
index 075cc3290691481e02340264f46817ccc0966d66..327bbe1a1bf9207b9b7ca8bd32f7689f112ef3c8 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReProgramArgs.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReProgramArgs : public ReTestUnit {
index 7d2285c016ba276eef4721ddf7ca772c35256122..6615e7b49d91a70f9c1afd4a458c7e3784231b0a 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReRandomizer.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 #include "math/remath.hpp"
 
index 6fc45b4b20f50f9f013cd87c2bb42ee47de33c91..11d890135405e40fe55a7e4832f25a98833d41f9 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReSeqArray.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReSeqList : public ReTestUnit {
index 9da0d4da04c25a523b231ecb416b7ec404252ec9..a3199fca50fc3b212f7af8c030b6c1acbd72f726 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReReStringList.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReStringList : public ReTestUnit {
index 483245444fe63d61b968073f98317964f0a1cb7c..6a784c1d1f218c41758627b2b51a6b9831b81688 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReStringUtils.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReStringUtils : public ReTestUnit {
index 48688fff9da17094fcae156a8ed66c57b4b5716d..ca3c12aa0c79835cdd28ee2a55604d1bed8793c5 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReTest.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestTestUnit : public ReTestUnit {
index 3ef63661578ed1e185e80b4c960bde655e43c8f7..4c9c0c21204984760bac482b87afb44c4a8630fa 100644 (file)
@@ -1,7 +1,10 @@
 /*
  * cuReTraverser.cpp
  *
- *  Created on: 23.12.2014
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
@@ -13,7 +16,7 @@ class TestReTraverser : public ReTestUnit {
 public:
        TestReTraverser() : ReTestUnit("ReTraverser", __FILE__){
         m_base = testDir();
-        m_base.append("traverser").append(ReTraverser::m_separatorStr, -1);
+        m_base.append("traverser").append(OS_SEPARATOR, -1);
         _mkdir(m_base.str());
                run();
        }
@@ -23,7 +26,7 @@ private:
     void makeDir(const char* relPath){
         ReByteBuffer path(m_base);
         path.append("/").append(relPath);
-        path.replaceAll("/", 1, ReTraverser::m_separatorStr, -1);
+        path.replaceAll("/", 1, OS_SEPARATOR, -1);
         _mkdir(path.str());
         struct stat info;
         if (stat(path.str(), &info) != 0){
@@ -33,7 +36,7 @@ private:
     void makeFile(const char* relPath){
         ReByteBuffer path(m_base);
         path.append("/").append(relPath);
-        path.replaceAll("/", 1, ReTraverser::m_separatorStr, -1);
+        path.replaceAll("/", 1, OS_SEPARATOR, -1);
         createFile(path.str(), relPath);
         struct stat info;
         if (stat(path.str(), &info) != 0){
@@ -153,8 +156,8 @@ private:
         ReByteBuffer path, expected;
         checkT(hash.get(ReByteBuffer(node), path));
         expected.set(parent, -1);
-        if (! expected.endsWith(ReTraverser::m_separatorStr))
-            expected.append(ReTraverser::m_separatorStr);
+        if (! expected.endsWith(OS_SEPARATOR))
+            expected.append(OS_SEPARATOR);
         if (! path.endsWith(expected.str(), -1))
             checkT(false); 
     }
@@ -163,8 +166,8 @@ private:
                RePatternList patterns;
                // exclude */cache/*
                ReByteBuffer buffer(";*;-*");
-               buffer.append(ReTraverser::m_separatorStr).append("cache")
-                       .append(ReTraverser::m_separatorStr);
+               buffer.append(OS_SEPARATOR).append("cache")
+                       .append(OS_SEPARATOR);
                patterns.set(buffer.str());
                traverser.setDirPattern(&patterns);
                int level = 0;
@@ -196,8 +199,8 @@ private:
         buffer.set(list.strOf(0), list.strLengthOf(0));
         checkT(buffer.startsWith("1\t"));
         expected.set(m_base.str(), m_base.length()).append("dir1", -1)
-            .append(ReTraverser::m_separatorStr);
-        // .append(ReTraverser::m_separatorStr, -1)
+            .append(OS_SEPARATOR);
+        // .append(OS_SEPARATOR, -1)
         checkT(buffer.endsWith(expected.str()));
         
         buffer.setLength(0);
@@ -207,13 +210,13 @@ private:
         buffer.set(list.strOf(0), list.strLengthOf(0));
         checkT(buffer.startsWith("      0.000074 MB       3       4\t"));
         expected.set(m_base.str(), m_base.length()).append("dir1", -1)
-             .append(ReTraverser::m_separatorStr);
+             .append(OS_SEPARATOR);
         checkT(buffer.endsWith(expected.str()));
 
         buffer.set(list.strOf(1), list.strLengthOf(1));
         checkT(buffer.startsWith("      0.000008 MB       1       0\t"));
         expected.set(m_base.str(), m_base.length()).append("dir2", -1)
-             .append(ReTraverser::m_separatorStr);
+             .append(OS_SEPARATOR);
         checkT(buffer.endsWith(expected.str()));
 
         buffer.set(list.strOf(2), list.strLengthOf(2));
index e6d0aea1e73340e5f48e0c6268b9e94ceaa22fc9..64c1928d9fb0504e911b864094f65e67529f20a9 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReVarArgs.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReVarArgs : public ReTestUnit, public ReVarArgTrigger {
index 4ee28850b849e035d127b8e7276ce1353691390e..798e8844f7eac4c4c0a60e9269a9b99d1a107c37 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * cuReConfig.cpp
+ *
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
+ */
 #include "base/rebase.hpp"
 
 class TestReConfigFile : public ReTestUnit {
index e5fe75dd382c3c0320a118b8081f96b2a7147534..2d9cb084ea5ebd9271365f75ad9bd54f44d6e540 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * testall.cpp
  *
- *  Created on: 24.11.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 #include "base/rebase.hpp"
 #include "os/reos.hpp"
index bb3b9737f890913ceabf448ac1aaf7f61781819c..7ad39e62420c12e242adcefee2a044142e802fb1 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReObfuscator.cpp
  *
- *  Created on: 13.11.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index 38f5fa9141c098be3e7419378d69ec8518ba8605..1740bcc77cc088436b01e7e76e031230e1abae36 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * ReObfuscator.h
+ * ReObfuscator.hpp
  *
- *  Created on: 13.11.2010
- *      Author: wk
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REOBFUSCATOR_H_
index f1d4ab99eb1a381c02ebb8b68c94db8317062fac..7ff8cad78a6c6731b17853f6481266f277995751 100644 (file)
@@ -1,7 +1,10 @@
 /*
  * ReRandomizer.cpp
  *
- *  Created on: 01.11.2010
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 
index 63bd3c8183f9c71851c9c2ea1ed9e52eebfe6f51..fec939566d2661d637a9c8b081a047e946b31e32 100644 (file)
@@ -1,7 +1,10 @@
 /*
- * ReRandomizer.h
+ * ReRandomizer.hpp
  *
- *  Created on: 01.11.2010
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef RANDOMIZER_H_
index d9233c39f579095f80fce567a9f72440513dfd5c..ac6ccd4ecb5b4d2bc4925d5401969f457116b1c2 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * remath.hpp
  *
- *  Created on: 23.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef REMATH_HPP_
index b0d09dcbc9676612299747658d98a7bec9f21400..b088e7cd5b8f66d145eca2a6f523d70a4f1f7d2b 100644 (file)
@@ -1,8 +1,10 @@
 /*
- * DirTools.cpp
+ * ReDirTools.cpp
  *
- *  Created on: 30.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
@@ -117,18 +119,6 @@ ReDirOptions::~ReDirOptions(){
        close();
        delete[] m_compoundUsage;
 }
-/**
- * Initializes the compound usage message array.
- *
- * @param size      the size of the array: size = (field1 + field2 + ...) * sizeof(const char*)
- */
-void ReDirOptions::initCompoundUsage(size_t size){
-    delete[] m_compoundUsage;
-    int count = size / sizeof m_compoundUsage[0];
-    m_compoundUsage = new const char*[count];
-    memset(m_compoundUsage, 0, size);
-    m_countCompoundUsage = count;
-}
 /**
  * Adds a usage component to the compound usage message list.
  * @param usage     a string vector containing a part of the usage message
@@ -171,8 +161,6 @@ void ReDirOptions::addStandardFilterOptions(){
             "units: m(inutes) h(hours), d(days). Default: m(inutes)\n"
             "examples: -o25 --older-than=30d -o24h -o2009.3.2/12:00 -o1999.01.01"),
         'o', "older-than", false, NULL);
-ReByteBuffer buffer;
-const char* ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addString("pathpattern", 
         i18n("a list of patterns for the path (without basename)\n"
             "the separator is the first character of the list\n"
@@ -182,7 +170,6 @@ const char* ptr = m_programArgs.getString("older", buffer);
             "and none of the 'not patterns' matches\n"
             "examples: ';*;-*/.git/' ',*/cache/,*/temp/"),
                'P', "path-pattern", false, NULL);
-ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addString("nodepattern",
         i18n("a list of patterns for the basename (name without path) separated by ';'\n"
             "Each pattern can contain '*' as wildcard\n"
@@ -191,16 +178,13 @@ ptr = m_programArgs.getString("older", buffer);
             "of the 'not patterns' matches\n"
             "examples: '*.cpp;*.hpp;Make*' '*;-*.bak;-*~"),
         'p', "basename-pattern", false, NULL);
-ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addBool("quiet",
         i18n("no additional information like runtime"),
         'q', "quiet", false);
-ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addInt("trace",
         i18n("all <number> seconds the current path will be traced\n"
             "0: no trace"),
         'T', "trace-interval", 0);
-ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addString("type",
         i18n("the file type\n"
             "<string> is a list of <v> values:\n"
@@ -209,27 +193,23 @@ ptr = m_programArgs.getString("older", buffer);
             "<v>-sets: S(pecial)=bcspo N(ondir)=Slr\n"
             "examples: -td --type=dr -tNi"), 
         't', "type", false, NULL);
-ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addString("younger",
         i18n("the modification date is younger than <string>\n"
             "<string> is a date (e.g. 2015.02.17) or number followed by an unit\n"
             "units: m(inutes) h(hours), d(days). Default: m(inutes)"),
         'y', "younger-than", false, NULL);
-ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addString("maxsize",
         i18n("the filesize is greater or equal <string>\n"
             "<string> is a number followed by an unit\n"
             "units: b(yte) k(Byte) K(iByte) m(Byte), M(iByte), g(Byte) G(iByte)\n"
             "examples: -Z50m --max-size=1G"),
         'Z', "max-size", false, NULL);
-ptr = m_programArgs.getString("older", buffer);
     m_programArgs.addString("minsize",
         i18n("the filesize is greater or equal <string>\n"
             "<string> is a number followed by an unit\n"
             "units: b(yte) k(Byte) K(iByte) m(Byte), M(iByte), g(Byte) G(iByte)\n"
             "examples: -z50m --min-size=1G"),
         'z', "min-size", false, NULL);
-ptr = m_programArgs.getString("older", buffer);
 }
 
 /**
@@ -429,43 +409,6 @@ ReDirStatus_t::Type_t ReDirOptions::checkType(const char* value){
     return (ReDirStatus_t::Type_t) rc;
 }
 
-/**
- * Sets the standard filter options given by the program arguments.
- *
- * @param filter    OUT: the filter to set
- */
-void ReDirOptions::setFilterFromProgramArgs(ReDirEntryFilter_t& filter){
-    ReByteBuffer buffer;
-    if (m_programArgs.getString("younger", buffer)[0] != '\0')
-        filter.m_maxAge = checkDate(buffer.str());
-    if (m_programArgs.getString("older", buffer)[0] != '\0')
-        filter.m_minAge = checkDate(buffer.str());
-    if (m_programArgs.getString("maxsize", buffer)[0] != '\0')
-        filter.m_maxSize = checkSize(buffer.str());
-    if (m_programArgs.getString("minsize", buffer)[0] != '\0')
-        filter.m_minSize = checkSize(buffer.str());
-    if (m_programArgs.getString("type", buffer)[0] != '\0')
-        filter.m_types = checkType(buffer.str());
-    filter.m_minDepth = m_programArgs.getInt("mindepth");
-    filter.m_maxDepth = m_programArgs.getInt("maxdepth");
-    if (m_programArgs.getString("nodepattern", buffer)[0] != '\0'){
-        checkPatternList(buffer.str());
-        m_nodePatterns.set(buffer.str());
-        filter.m_nodePatterns = &m_nodePatterns;
-    }
-    if (m_programArgs.getString("pathpattern", buffer)[0] != '\0'){
-        checkPatternList(buffer.str());
-        m_pathPatterns.set(buffer.str());
-        filter.m_pathPatterns = &m_pathPatterns;
-    }
-    filter.m_traceInterval = m_programArgs.getInt("trace");
-       if (m_programArgs.getString("output", buffer)[0] != '\0'){
-               if ( (m_output = fopen(buffer.str(), "w")) == NULL){
-                       help("cannot open output file", buffer.str());
-                       m_output = stdout;
-               }
-       }
-}
 /**
  * Prints a help message, the error message and exits.
  *
@@ -498,6 +441,9 @@ void ReDirOptions::checkStandardFilterOptions(){
     checkPatternList(m_programArgs.getString("pathpattern", buffer));    
 }
 
+/**
+ * Frees the resources.
+ */
 void ReDirOptions::close(){
        if (m_output != stdout){
                fclose(m_output);
@@ -505,6 +451,55 @@ void ReDirOptions::close(){
        }
 }
 
+/**
+ * Initializes the compound usage message array.
+ *
+ * @param size      the size of the array: size = (field1 + field2 + ...) * sizeof(const char*)
+ */
+void ReDirOptions::initCompoundUsage(size_t size){
+    delete[] m_compoundUsage;
+    int count = size / sizeof m_compoundUsage[0];
+    m_compoundUsage = new const char*[count];
+    memset(m_compoundUsage, 0, size);
+    m_countCompoundUsage = count;
+}
+/**
+ * Sets the standard filter options given by the program arguments.
+ *
+ * @param filter    OUT: the filter to set
+ */
+void ReDirOptions::setFilterFromProgramArgs(ReDirEntryFilter_t& filter){
+    ReByteBuffer buffer;
+    if (m_programArgs.getString("younger", buffer)[0] != '\0')
+        filter.m_maxAge = checkDate(buffer.str());
+    if (m_programArgs.getString("older", buffer)[0] != '\0')
+        filter.m_minAge = checkDate(buffer.str());
+    if (m_programArgs.getString("maxsize", buffer)[0] != '\0')
+        filter.m_maxSize = checkSize(buffer.str());
+    if (m_programArgs.getString("minsize", buffer)[0] != '\0')
+        filter.m_minSize = checkSize(buffer.str());
+    if (m_programArgs.getString("type", buffer)[0] != '\0')
+        filter.m_types = checkType(buffer.str());
+    filter.m_minDepth = m_programArgs.getInt("mindepth");
+    filter.m_maxDepth = m_programArgs.getInt("maxdepth");
+    if (m_programArgs.getString("nodepattern", buffer)[0] != '\0'){
+        checkPatternList(buffer.str());
+        m_nodePatterns.set(buffer.str());
+        filter.m_nodePatterns = &m_nodePatterns;
+    }
+    if (m_programArgs.getString("pathpattern", buffer)[0] != '\0'){
+        checkPatternList(buffer.str());
+        m_pathPatterns.set(buffer.str());
+        filter.m_pathPatterns = &m_pathPatterns;
+    }
+    filter.m_traceInterval = m_programArgs.getInt("trace");
+       if (m_programArgs.getString("output", buffer)[0] != '\0'){
+               if ( (m_output = fopen(buffer.str(), "w")) == NULL){
+                       help("cannot open output file", buffer.str());
+                       m_output = stdout;
+               }
+       }
+}
 /**
  * Constructor.
  */
@@ -540,28 +535,6 @@ ReDirStatisticData& ReDirStatisticData::operator =(const ReDirStatisticData& sou
        m_path = source.m_path;
        return *this;
 }
-/**
- * Initializes the data of the instance.
- */
-void ReDirStatisticData::clear(){
-       m_sizes = 0;
-       m_files = 0;
-       m_dirs = 0;
-       m_path.setLength(0);
-}
-
-/**
- * Adds the data from another instance.
- *
- * @param source               the other instance
- * @return                     the instance itself
- */
-ReDirStatisticData& ReDirStatisticData::add(const ReDirStatisticData& source){
-       m_sizes += source.m_sizes;
-       m_files += source.m_files;
-       m_dirs += source.m_dirs;
-       return *this;
-}
 
 /**
  * Constructor.
@@ -582,6 +555,7 @@ ReDirStatistic::ReDirStatistic(int deltaList, int deltaBuffer) :
         i18n("trace the current path every <number> seconds.\n"
             "0: no trace"),
         't', "trace-interval", 60);
+    addStandardFilterOptions();
 }
 /**
  * Destructor.
@@ -590,43 +564,27 @@ ReDirStatistic::~ReDirStatistic(){
 }
 
 /**
- * Build the statistic and print the results.
+ * Adds the data from another instance.
  *
- * @param arc   count of arguments in <code>argv</code>
- * @param argv  the program arguments. 
+ * @param source               the other instance
+ * @return                     the instance itself
  */
-void ReDirStatistic::run(int argc, const char* argv[]){
-    time_t start = time(NULL);
-    try {
-        m_programArgs.init(argc, argv);
-        if (m_programArgs.getArgCount() < 1)
-            m_programArgs.help("statistic: missing path", false, stdout);
-        int depth = 1;
-        if (m_programArgs.getArgCount() > 1)
-            depth = atol(m_programArgs.getArg(1));
-        ReDirStatistic statistic;
-        statistic.setTraceInterval(m_programArgs.getInt("trace"));
-        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);
-        ReByteBuffer buffer;
-        for (size_t ix = 0; ix < list.count(); ix++){
-            buffer.set(list.strOf(ix), list.strLengthOf(ix));
-            fprintf(m_output, "%s\n", buffer.str());
-        }
-        if (! m_programArgs.getBool("quiet")){
-            int duration = int(time(NULL) - start);
-            fprintf(m_output, "Duration: ");
-            if (duration >= 3600)
-                fprintf(m_output, "%d:", duration / 3600);
-            fprintf(m_output, "%02d:%02d\n", duration % 3600 / 60, duration % 60);
-        }
-    } catch (ReOptionException& exc) {
-        m_programArgs.help(exc.getMessage(), false, stdout);
-    }
+ReDirStatisticData& ReDirStatisticData::add(const ReDirStatisticData& source){
+       m_sizes += source.m_sizes;
+       m_files += source.m_files;
+       m_dirs += source.m_dirs;
+       return *this;
+}
+/**
+ * Initializes the data of the instance.
+ */
+void ReDirStatisticData::clear(){
+       m_sizes = 0;
+       m_files = 0;
+       m_dirs = 0;
+       m_path.setLength(0);
 }
+
 /**
  * Calculates the statistic of a directory tree.
  *
@@ -635,7 +593,10 @@ void ReDirStatistic::run(int argc, const char* argv[]){
 const ReStringList& ReDirStatistic::calculate(const char* base, int level,
                        void (*formatter)(const ReDirStatisticData& data, ReDirStatistic& parent,
                                ReByteBuffer& line)){
+   ReDirEntryFilter_t filter;
        ReTraverser traverser(base);
+   setFilterFromProgramArgs(filter);
+   traverser.setPropertiesFromFilter(&filter);
        if (level > 1024)
                level = 1024;
        else if (level < 0)
@@ -650,10 +611,11 @@ const ReStringList& ReDirStatistic::calculate(const char* base, int level,
        ReDirStatisticData* current = dataStack[0];
        current->m_path.set(base, -1);
        ReByteBuffer line;
-    int traceCount = 0;
+       int traceCount = 0;
+       bool useFilter = filter.m_minSize > 0 || filter.m_maxSize != -1
+                               || filter.m_minAge != 0 || filter.m_maxAge != 0
+                               || m_nodePatterns.count() > 0;
        while( (entry = traverser.rawNextFile(currentDepth))){
-               //@todo
-               ReByteBuffer dummy(entry->m_path); dummy.append(entry->node());
                if (currentDepth <= level && ! entry->m_path.equals(current->m_path)){
                        if (currentDepth <= topOfStack){
                                // close the entries of the stack above the new top level:
@@ -688,7 +650,7 @@ const ReStringList& ReDirStatistic::calculate(const char* base, int level,
                }
                if (entry->isDirectory()){
                        current->m_dirs++;
-               } else {
+               } else if (! useFilter || filter.match(*entry)){
                        current->m_sizes += entry->fileSize();
                        current->m_files++;
             if (++traceCount % 100 == 0 && m_traceInterval > 0){
@@ -720,6 +682,44 @@ const ReStringList& ReDirStatistic::calculate(const char* base, int level,
        return m_list;
 }
 
+/**
+ * Build the statistic and print the results.
+ *
+ * @param arc   count of arguments in <code>argv</code>
+ * @param argv  the program arguments.
+ */
+void ReDirStatistic::run(int argc, const char* argv[]){
+    time_t start = time(NULL);
+    try {
+        m_programArgs.init(argc, argv);
+        if (m_programArgs.getArgCount() < 1)
+            m_programArgs.help("statistic: missing path", false, stdout);
+        int depth = 1;
+        if (m_programArgs.getArgCount() > 1)
+            depth = atol(m_programArgs.getArg(1));
+        ReDirStatistic statistic;
+        statistic.setTraceInterval(m_programArgs.getInt("trace"));
+        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);
+        ReByteBuffer buffer;
+        for (size_t ix = 0; ix < list.count(); ix++){
+            buffer.set(list.strOf(ix), list.strLengthOf(ix));
+            fprintf(m_output, "%s\n", buffer.str());
+        }
+        if (! m_programArgs.getBool("quiet")){
+            int duration = int(time(NULL) - start);
+            fprintf(m_output, "Duration: ");
+            if (duration >= 3600)
+                fprintf(m_output, "%d:", duration / 3600);
+            fprintf(m_output, "%02d:%02d\n", duration % 3600 / 60, duration % 60);
+        }
+    } catch (ReOptionException& exc) {
+        m_programArgs.help(exc.getMessage(), false, stdout);
+    }
+}
 /**
  * Formats a line like the du (disk usage) command.
  *
@@ -758,21 +758,6 @@ void formatWithSizeFilesAndDirs(const ReDirStatisticData& data,
         data.m_sizes / 1E6, data.m_files, data.m_dirs);
        line.append(buffer, -1).append(data.m_path);
 }
-/**
- * Prints an message how to use the program and exits.
- *
- * @param msg       an error message
- * @param msg2      an addition to the error message or NULL
- */
-void ReDirTools::usage(const char* msg, const char* msg2){
-    printf ("Version: %s\n", m_version);
-    printf ("usage: dirtool <command> <opt>\n");
-    statisticUsage();
-    if (msg != NULL)
-        printf ("+++ %s%s\n", msg, msg2 == NULL ? "" : msg2);
-    exit(1);
-}
-
 /**
  * Prints a vector of lines.
  * 
@@ -792,6 +777,21 @@ void ReDirTools::statisticUsage(){
     statistic.programArgs().help(NULL, false, stdout);
 }
 
+/**
+ * Prints an message how to use the program and exits.
+ *
+ * @param msg       an error message
+ * @param msg2      an addition to the error message or NULL
+ */
+void ReDirTools::usage(const char* msg, const char* msg2){
+    printf ("Version: %s\n", m_version);
+    printf ("usage: dirtool <command> <opt>\n");
+    statisticUsage();
+    if (msg != NULL)
+        printf ("+++ %s%s\n", msg, msg2 == NULL ? "" : msg2);
+    exit(1);
+}
+
 /**
  * Constructor.
  */
@@ -827,8 +827,7 @@ void ReDirList::list(int argc, const char* argv[]){
         for (int ix = 0; noPath || ix < m_programArgs.getArgCount(); ix++){
             ReTraverser traverser(noPath ? "." : m_programArgs.getArg(ix));
             noPath = false;
-            traverser.setMinLevel(filter.m_maxDepth);
-            traverser.setMaxLevel(filter.m_maxDepth);
+                       traverser.setPropertiesFromFilter(&filter);
             int level;
             ReDirStatus_t* entry;
             while( (entry = traverser.nextFile(level, &filter)) != NULL){
@@ -977,8 +976,7 @@ void ReDirBatch::createBatch(int argc, const char* argv[]){
 #endif
         for (int ix = 0; ix < m_programArgs.getArgCount(); ix++){
             ReTraverser traverser(m_programArgs.getArg(ix));
-            traverser.setMinLevel(filter.m_maxDepth);
-            traverser.setMaxLevel(filter.m_maxDepth);
+            traverser.setPropertiesFromFilter(&filter);
             int level;
             ReDirStatus_t* entry;
             ReByteBuffer line;
@@ -1029,7 +1027,7 @@ void makeDirWithParents(ReByteBuffer& path, int minWidth){
     struct stat info;
     do {
         path2 = path;
-        int ix = path.indexOf(ReTraverser::m_separatorStr, minWidth);
+        int ix = path.indexOf(OS_SEPARATOR, minWidth);
         path2.setLength(minWidth);
         
     } while(false);
@@ -1162,7 +1160,7 @@ bool ReDirSync::copyFile(const char* source, time_t modified, int64_t size,
  */
 void ReDirSync::synchronize(int argc, const char* argv[]){
     ReDirEntryFilter_t filter;
-    const char* sep = ReTraverser::m_separatorStr;
+    const char* sep = OS_SEPARATOR;
     struct stat info;
     try {
         time_t start = time(NULL);
@@ -1208,8 +1206,7 @@ void ReDirSync::synchronize(int argc, const char* argv[]){
             size_t ixTargetRelative = target.length();
 
             ReTraverser traverser(source.str());
-            traverser.setMinLevel(filter.m_maxDepth);
-            traverser.setMaxLevel(filter.m_maxDepth);
+            traverser.setPropertiesFromFilter(&filter);
             int level;
             ReDirStatus_t* entry;
             ReByteBuffer line;
@@ -1267,17 +1264,6 @@ void ReDirSync::synchronize(int argc, const char* argv[]){
     }
 }
 
-/**
- * Gets the arguments for the "statistic" command and execute this.
- *
- * @param argc      the number of arguments
- * @param argav     the argument vector
- */
-void ReDirTools::list(int argc, const char* argv[]){
-    ReDirList lister;
-    lister.list(argc, argv);
-}
-
 /**
  * Gets the arguments for the "batch" command and execute this.
  *
@@ -1339,9 +1325,9 @@ void ReDirTools::help(int argc, const char* argv[]){
  * @param argc      the number of arguments
  * @param argav     the argument vector
  */
-void ReDirTools::statistic(int argc, const char* argv[]){
-    ReDirStatistic statistic;
-    statistic.run(argc, argv);
+void ReDirTools::list(int argc, const char* argv[]){
+    ReDirList lister;
+    lister.list(argc, argv);
 }
 
 /**
@@ -1376,3 +1362,15 @@ int ReDirTools::main(int argc, char* orgArgv[]){
        ReLogger::freeGlobalLogger();
     return 0;
 }
+
+/**
+ * Gets the arguments for the "statistic" command and execute this.
+ *
+ * @param argc      the number of arguments
+ * @param argav     the argument vector
+ */
+void ReDirTools::statistic(int argc, const char* argv[]){
+    ReDirStatistic statistic;
+    statistic.run(argc, argv);
+}
+
index 12b571a2352f1e75e41ea1006bc7211f023bc3f4..f1d5afb740ee5e6c176a946c82d6e6aa54f16ccf 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * DirTools.hpp
  *
- *  Created on: 30.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef OS_DIRTOOLS_HPP_
@@ -19,11 +21,11 @@ public:
     const char* checkPatternList(const char* value);
     int64_t checkSize(const char* value);
     void checkStandardFilterOptions();
-       void close();
     ReDirStatus_t::Type_t checkType(const char* value);
        /** Returns the compound usage message.
         * @return the compound usage message
         */
+       void close();
     const char** compoundUsage() const
     { return m_compoundUsage; }
     void initCompoundUsage(size_t size);
index d87066f456dfc289421f2865decf1d1057b6b495..5703154047469f84305c0074cb804e0d96f1040c 100644 (file)
@@ -1,21 +1,15 @@
 /*\r
  * ReTraverser.cpp\r
  *\r
- *  Created on: 23.12.2014\r
- *      Author: hm\r
+ * License: Public domain\r
+ * Do what you want.\r
+ * No warranties and disclaimer of any damages.\r
+ * The latest sources: https://github.com/republib\r
  */\r
 \r
 #include "base/rebase.hpp"\r
 #include "os/reos.hpp"\r
 \r
-#ifdef __linux__\r
-const char ReTraverser::m_separator = '/';\r
-const char* const ReTraverser::m_separatorStr = "/";\r
-#elif defined __WIN32__\r
-const char ReTraverser::m_separator = '\\';\r
-const char* const ReTraverser::m_separatorStr = "\\";\r
-#endif\r
-\r
 /**\r
  * Constructor.\r
 */\r
@@ -339,8 +333,6 @@ bool ReDirEntryFilter_t::match(ReDirStatus_t& entry){
                if (0 == (entry.type() & m_types))\r
                        break;\r
         int64_t size = entry.fileSize();\r
-        if (strstr(entry.node(), ".exe"))\r
-            ReByteBuffer breaker;\r
         if (m_minSize > 0 && size < m_minSize)\r
                        break;\r
                if (m_maxSize >= 0 && size > m_maxSize)\r
@@ -351,8 +343,6 @@ bool ReDirEntryFilter_t::match(ReDirStatus_t& entry){
                        break;\r
                if (m_nodePatterns != NULL && ! m_nodePatterns->match(entry.node()))\r
                        break;\r
-               if (m_pathPatterns != NULL && ! m_pathPatterns->match(entry.m_path.str()))\r
-                       break;\r
                rc = true;\r
        } while(false);\r
        return rc;\r
@@ -390,7 +380,7 @@ ReTraverser::ReTraverser(const char* base) :
        memset(m_dirs, 0, sizeof m_dirs);\r
        m_dirs[0] = new ReDirStatus_t();\r
        // remove a preceeding "./". This simplifies the pattern expressions:\r
-       if (m_base.startsWith(ReByteBuffer(".").append(m_separatorStr, 1).str())){\r
+       if (m_base.startsWith(ReByteBuffer(".").append(OS_SEPARATOR, 1).str())){\r
                m_base.remove(0, 2);\r
        }\r
 }\r
@@ -523,14 +513,24 @@ bool ReTraverser::initEntry(const ReByteBuffer& parent, const char* node, int le
         current->m_passNo = 1;\r
         if (level >= 0){\r
             current->m_path.set(parent.str(), parent.length());\r
-            if (! parent.endsWith(m_separatorStr))\r
-                current->m_path.append(m_separatorStr);\r
+            if (! parent.endsWith(OS_SEPARATOR))\r
+                current->m_path.append(OS_SEPARATOR);\r
             if (node != NULL)\r
-                current->m_path.append(node).append(m_separatorStr);\r
+                current->m_path.append(node).append(OS_SEPARATOR);\r
         }\r
       rc = current->findFirst();\r
        }\r
     return rc;\r
 }\r
 \r
+/**\r
+ * Sets some properties from a filter.\r
+ *\r
+ * @param filter       the filter with the properties to set\r
+ */\r
+void ReTraverser::setPropertiesFromFilter(ReDirEntryFilter_t* filter){\r
+       m_minLevel = filter->m_minDepth;\r
+       m_maxLevel = filter->m_maxDepth;\r
+       m_dirPatterns = filter->m_pathPatterns;\r
+}\r
 \r
index 24e161b3b964d6c68d41f28005d9fa09a573f872..68c3424c363ff0543a016e6b0c7e9f71facadb82 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * RpTraverser.hpp
  *
- *  Created on: 23.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef OS_RETRAVERSER_HPP_
@@ -119,6 +121,7 @@ public:
     */
     void setMinLevel(int value)
     { m_minLevel = value; }
+    void setPropertiesFromFilter(ReDirEntryFilter_t* filter);
 protected:
        bool initEntry(const ReByteBuffer& parent, const char* node, int level);
        void freeEntry(int level);
@@ -145,9 +148,6 @@ protected:
        /// a subdirectory will be entered only if this pattern list matches
        /// if NULL any directory will be entered
        RePatternList* m_dirPatterns;
-public:
-       static const char m_separator;
-       static const char* const m_separatorStr;
 };
 
 #endif /* OS_RETRAVERSER_HPP_ */
index 3b513a9f53af713a7005c3a4fc7ace9fc59f96a3..cbdb7b724831c000a00225729bfa4577a609b926 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * reos.hpp
  *
- *  Created on: 23.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef OS_REOS_HPP_
index 80b37f61e80ffa18031866257daa550ee915e249..4ebae0d9a6a9c88889c9e618092fd4df36c20743 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReMatcher.cpp
  *
- *  Created on: 25.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #include "base/rebase.hpp"
index 3567e9b9a05a3b7385a2d1bcc09a5a963657ba21..9e7b0e54e0111b851e1afa2de305f1d8777d0d5e 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * ReMatcher.hpp
  *
- *  Created on: 25.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef STRING_REMATCHER_HPP_
@@ -87,15 +89,21 @@ public:
        RePatternList();
        ~RePatternList();
 public:
+       /** @brief Returns the number of entries in the list.
+        * @return the count of patterns in the list
+        */
+   inline int count() const {
+        return m_count;
+   }
        void destroy();
        bool match(const char* pattern);
+   /** Returns the original pattern string.
+    * @return the string describing the patterns.
+    */
+   const char* patternString() const
+   { return m_patternString.str(); }
        void set(const char* patterns, bool ignoreCase = false,
                                const char* separator = NULL, const char* notPrefix = "-");
-    /** Returns the original pattern string.
-     * @return the string describing the patterns.
-     */
-    const char* patternString() const
-    { return m_patternString.str(); }
 private:
        int setOne(int index, const char* pattern, size_t patternLength,
                                bool ignoreCase, const ReByteBuffer& notPrefix);
index d233d62096e9749a75b95d6f284b5dc6bb21fdbd..59f1988b41953686d4df780d65f4db826762a30f 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * restring.hpp
  *
- *  Created on: 25.12.2014
- *      Author: hm
+ * License: Public domain
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * The latest sources: https://github.com/republib
  */
 
 #ifndef STRING_RESTRING_HPP_