]> gitweb.hamatoma.de Git - crepublib/commitdiff
win corrections
authorHamatoma <git.tortouse@hm.f-r-e-i.de>
Sat, 21 Feb 2015 00:10:51 +0000 (01:10 +0100)
committerHamatoma <git.tortouse@hm.f-r-e-i.de>
Sat, 21 Feb 2015 00:10:51 +0000 (01:10 +0100)
base/rebase.hpp
cunit/cuReDirTools.cpp
cunit/cuReHashList.cpp
cunit/cuReMD5.cpp
os/ReDirTools.cpp
os/ReDirTools.hpp
os/ReTraverser.hpp
os/reos.hpp

index d22d67b13003d0eeecad5d504ac77c6f540992dc..a45037e6cc27c9345efd2135711bfeea18b6e857 100644 (file)
@@ -14,7 +14,6 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <time.h>
 #include <errno.h>
 #include <ctype.h>
@@ -24,6 +23,7 @@
 
 #if defined __linux__
 
+#      include <sys/time.h>
 #      include <stddef.h>
 #      include <dirent.h>
 #      include <fnmatch.h>
index 578c22301d74d22ffc7b33e204407ab5f8afd0fb..d2d89946107338237b56d8a910a3579876d79741 100644 (file)
@@ -78,7 +78,11 @@ private:
         ReDirList().run(2, argv);
     }
        int secOfFileTime(ReFileTime_t data){
+#if defined __linux__
                return data.tv_sec;
+#elif defined __WIN32__
+               return (int) ReDirStatus_t::filetimeToTime(&data);
+#endif
        }
     void testCopyFile(){
 #if defined __linux__
@@ -246,7 +250,7 @@ private:
                checkEqu(expected.count(), current.count());
                ReByteBuffer line;
                ReStringList cols;
-               for (int ix = 0; ix < current.count(); ix++){
+               for (size_t ix = 0; ix < current.count(); ix++){
                        line.setLength(0).append(current.strOf(ix), -1);
                        cols.split(expected.strOf(ix), '*');
                        checkT(line.startsWith(cols.strOf(0)));
index a8ee236047914a15e8ca9c47eb3fca3741601549..6990a6e7d2f56fc80d0da53bbd5f3a3712aeb7f1 100644 (file)
@@ -32,7 +32,6 @@ private:
                list.setSizes(4, maxKeys <= 0xffff ? 2 : 3);
                ReByteBuffer key, value;
                int64_t start = timer();
-               ReSeqArray::Tag tag;
                int ix;
                int collisions = 0;
                for(ix = 0; ix < maxKeys; ix++){
index 4bd88fc0d8745cdf4e6e885d4a5f8eec6f0373a5..f17df7ceda666d1af3adf5d563e5e897b43db7b2 100644 (file)
@@ -68,7 +68,7 @@ private:
                        max2 = random.nextInt(20);
                while(text.length() > 0){
                        int part = random.nextInt(32, 32 + 1 + max2);
-                       if (part > text.length())
+                       if (part > (int) text.length())
                                part = text.length();
                        md5.update((uint8_t*) text.str(), part);
                        text.remove(0, part);
index 0544b3bb062d7f3f3b75f2562a49801301d4819b..232b230ec1efcb7707c92eb5620096db3c4a846a 100644 (file)
@@ -747,7 +747,7 @@ void ReTool::processSingleFile(const char* filename){
 #if defined    __linux__\r
                        bool found = strcmp(entry.node(), name.str()) == 0;\r
 #elif defined __WIN32__\r
-                       bool found = stricmp(entry.node(), name.str()) == 0;\r
+                       bool found = _stricmp(entry.node(), name.str()) == 0;\r
 #endif\r
                        if (found && m_filter.match(entry)){\r
                                processFile(&entry);\r
@@ -1301,6 +1301,10 @@ static bool isAbsoluteTime(ReFileTime_t& time){
 #if defined __linux__\r
        return time.tv_sec >= time1980;\r
 #elif defined __WIN32__\r
+       static ReFileTime_t time2 = { 0, 0 };\r
+       if (time2.dwHighDateTime == 0 && time2.dwLowDateTime == 0)\r
+               ReDirStatus_t::timeToFiletime(time1980, time2);\r
+       return time2 > time;\r
 #endif\r
 }\r
 static void addRelativeTime(ReFileTime_t& absTime, const ReFileTime_t& relTime){\r
@@ -1311,8 +1315,12 @@ static void addRelativeTime(ReFileTime_t& absTime, const ReFileTime_t& relTime){
        }\r
        absTime.tv_sec += relTime.tv_sec;\r
 #elif defined __WIN32__\r
+       uint64_t absValue = ((uint64_t) absTime.dwHighDateTime << 32) | absTime.dwLowDateTime;\r
+       uint64_t relValue = ((uint64_t) relTime.dwHighDateTime << 32) | relTime.dwLowDateTime;\r
+       absValue += relValue;\r
+       absTime.dwHighDateTime = (uint32_t) (absValue >> 32);   \r
+       absTime.dwLowDateTime = (uint32_t) absValue;    \r
 #endif\r
-\r
 }\r
 /**\r
  * Processes one file.\r
@@ -1396,10 +1404,10 @@ ReErrNo_t ReDirTouch::touch(const char* filename, const ReFileTime_t& modified,
        HANDLE handle = CreateFile(filename, FILE_WRITE_ATTRIBUTES,\r
                FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,\r
                FILE_ATTRIBUTE_NORMAL, NULL);\r
-       if (handle == UNDEF_HANDLE)\r
+       if (handle == INVALID_HANDLE_VALUE)\r
                rc = GetLastError();\r
        else {\r
-               if (SetFileTime(handle, (LPFILETIME) NULL,(LPFILETIME) NULL,&thefiletime) != 0)\r
+               if (! SetFileTime(handle, (LPFILETIME) NULL, &accessed, &modified))\r
                        rc = GetLastError();\r
                CloseHandle(handle);\r
        }\r
index 259f415facd45c7a136a1b2f5cccee24b21aa2eb..c539d583a7aae77a4749ea7d409b183749a2633c 100644 (file)
@@ -68,7 +68,7 @@ typedef struct stat ReFileProperties_t;
 typedef struct {
        FILETIME m_modified;
        FILETIME m_accessed;
-       FileSize_t m_size;
+       ReFileSize_t m_size;
 } ReFileProperties_t;
 #endif
 
index 2b967f5e73cd25ffcd8a8b33e91bf5ec3d0ace4b..8606b0a1c9af72495799a9f9ad3b9e7dc43decc4 100644 (file)
@@ -25,6 +25,7 @@ inline bool filetimeIsUndefined(ReFileTime_t& time){
 #if defined __linux__
        return time.tv_sec == 0 && time.tv_nsec == 0;
 #elif defined __WIN32__
+       return time.dwHighDateTime == 0 && time.dwLowDateTime == 0;
 #endif
 }
 /** Sets the filetime to undefined.
@@ -34,6 +35,7 @@ inline void setFiletimeUndef(ReFileTime_t& time){
 #if defined __linux__
        time.tv_sec = time.tv_nsec = 0;
 #elif defined __WIN32__
+       time.dwHighDateTime =  time.dwLowDateTime = 0;
 #endif
 }
 
index f9aeaf4a66e750e7a2930bbd924370690f0537eb..74083daf929850769d39eb51418ad522266e5ea8 100644 (file)
  */
 inline bool operator >(const ReFileTime_t& time1, const ReFileTime_t& time2){
 #if defined __linux__
-       return time1.tv_sec > time1.tv_sec || time1.tv_sec == time2.tv_sec && time1.tv_nsec > time2.tv_nsec;
+       return time1.tv_sec > time2.tv_sec || time1.tv_sec == time2.tv_sec && time1.tv_nsec > time2.tv_nsec;
 #else
+       return time1.dwHighDateTime > time2.dwHighDateTime
+               || time1.dwHighDateTime == time2.dwHighDateTime 
+               && time1.dwLowDateTime > time2.dwLowDateTime;
 #endif
 }
 #include "os/ReTraverser.hpp"