]> gitweb.hamatoma.de Git - crepublib/commitdiff
ReDirTool:synchronize works (win)
authorHamatoma <git.tortouse@hm.f-r-e-i.de>
Tue, 3 Feb 2015 22:53:12 +0000 (23:53 +0100)
committerHamatoma <git.tortouse@hm.f-r-e-i.de>
Tue, 3 Feb 2015 22:53:12 +0000 (23:53 +0100)
dirtool.cpp [new file with mode: 0644]
os/ReDirTools.cpp
os/ReDirTools.hpp

diff --git a/dirtool.cpp b/dirtool.cpp
new file mode 100644 (file)
index 0000000..6b8c9c3
--- /dev/null
@@ -0,0 +1,12 @@
+// dirtool.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.\r
+//\r
+#include "base/rebase.hpp"\r
+#include "os/reos.hpp"\r
+\r
+int _tmain(int argc, _TCHAR* argv[])\r
+{\r
+       ReDirTools tool;\r
+       tool.main(argc, argv);\r
+       return 0;\r
+}\r
+\r
index d62827355a54735705c7db48414812908cf30c80..0805df4c86f44c9d1c701c3798b34a4a5e5d6c9c 100644 (file)
@@ -1070,9 +1070,12 @@ void ReDirBatch::createBatch(int argc, const char* argv[]){
  *
  * @param path      the name of the subdir to create
  */
-void ReDirSync::makeDirWithParents(const ReByteBuffer& path, int minWidth,
+void ReDirSync::makeDirWithParents(ReByteBuffer& path, int minWidth,
                        ReTraverser& traverser){
     struct stat info;
+       bool endsWithSlash = path.str()[path.length() - 1] == OS_SEPARATOR_CHAR;
+       if (endsWithSlash)
+               path.setLength(path.length() - 1);
        if (stat(path.str(), &info) != 0){
                ReFileProperties_t* props = NULL;
 #if defined __linux__
@@ -1081,6 +1084,8 @@ void ReDirSync::makeDirWithParents(const ReByteBuffer& path, int minWidth,
 #endif
                makeDirectory(path.str(), minWidth, props, ReLogger::globalLogger());
        }
+       if (endsWithSlash)
+               path.append(OS_SEPARATOR, 1);
 }
 /**
  * Constructor.
@@ -1206,8 +1211,8 @@ bool ReDirSync::copyFile(const char* source, ReFileProperties_t* properties,
                fclose(fpSource);
        }
 #elif defined __WIN32__
-    BOOL dummy;
-    rc = CopyFileExA(source, target, NULL, NULL, &dummy, COPY_FILE_NO_BUFFERING) != 0;
+    BOOL cancel = false;
+    rc = CopyFileExA(source, target, NULL, NULL, &cancel, COPY_FILE_NO_BUFFERING) != 0;
     int errNo = 0;
     if (! rc)
         errNo = GetLastError();
@@ -1402,8 +1407,9 @@ void ReDirSync::synchronize(int argc, const char* argv[]){
                                                continue;
                                        }
                                        // target younger than source?
+                                       int diff = info.st_mtime - entry->filetimeToTime(entry->modified());
                                        if (! ignoreDate && info.st_mtime - entry->filetimeToTime(entry->modified())
-                                                       > maxFileTimeDiff) {
+                                                       <= maxFileTimeDiff) {
                                                if (chatterMode)
                                                        fprintf(m_output, "=ignored: %s same time\n", targetRelativePath);
                                                continue;
@@ -1424,8 +1430,10 @@ void ReDirSync::synchronize(int argc, const char* argv[]){
         if (verbose){
             int duration = int(time(NULL) - start);
             fprintf(m_output, i18n(
-                               "=== copied: %d file(s) with %.6f MByte in %02d:%02d sec. Tree: %d dir(s) %d file(s) %.6f MByte\n"),
-                files, sumSizes / 1E6, duration / 60, duration % 60,
+                               "=== copied:    %02d:%02d sec  %7d file(s) %12.6f MByte (%.3f MB/sec).\n"
+                               "=== tree  :  %5d dir(s) %7d file(s) %12.6f MByte\n"),
+                duration / 60, duration % 60, files, sumSizes / 1E6, 
+                               sumSizes / 1E6 / (duration == 0 ? 1 : duration),
                                treeDirs, treeFiles, treeSumSizes / 1E6);
         }
     } catch(ReOptionException& exc){
index 1532aa82aac4e554178784cdb874c664d195627c..266593eb5dbd048eee6034573ec1b6bad569d15c 100644 (file)
@@ -78,7 +78,7 @@ public:
     void synchronize(int argc, const char* argv[]);
 protected:
        void copyFile(ReDirStatus_t* entry, const char* target);
-       void makeDirWithParents(const ReByteBuffer& path, int minWidth,
+       void makeDirWithParents(ReByteBuffer& path, int minWidth,
                                ReTraverser& traverser);
 public:
        static bool copyFile(const char* source, ReFileProperties_t* properties,