From: Hamatoma Date: Tue, 3 Feb 2015 22:53:12 +0000 (+0100) Subject: ReDirTool:synchronize works (win) X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=6f0331d6a1ec2d208ed16745654cf10be3969433;p=crepublib ReDirTool:synchronize works (win) --- diff --git a/dirtool.cpp b/dirtool.cpp new file mode 100644 index 0000000..6b8c9c3 --- /dev/null +++ b/dirtool.cpp @@ -0,0 +1,12 @@ +// dirtool.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung. +// +#include "base/rebase.hpp" +#include "os/reos.hpp" + +int _tmain(int argc, _TCHAR* argv[]) +{ + ReDirTools tool; + tool.main(argc, argv); + return 0; +} + diff --git a/os/ReDirTools.cpp b/os/ReDirTools.cpp index d628273..0805df4 100644 --- a/os/ReDirTools.cpp +++ b/os/ReDirTools.cpp @@ -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){ diff --git a/os/ReDirTools.hpp b/os/ReDirTools.hpp index 1532aa8..266593e 100644 --- a/os/ReDirTools.hpp +++ b/os/ReDirTools.hpp @@ -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,