From: kawi Date: Wed, 7 Jan 2015 14:43:50 +0000 (+0100) Subject: copyfile for windows X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=a338c75dd9673147475ccaf1517a81efaab5ff36;p=crepublib copyfile for windows --- diff --git a/cunit/cuReTraverser.cpp b/cunit/cuReTraverser.cpp index 81e76da..e2dc60d 100644 --- a/cunit/cuReTraverser.cpp +++ b/cunit/cuReTraverser.cpp @@ -59,7 +59,16 @@ private: checkSetFilterFromProgramArgs(); testDirStatistic(); testBasic(); + testCopyFile(); } + void testCopyFile(){ + ReByteBuffer src(m_base); + src.append("dir1/dir1_2/dir1_2_1/x1.txt"); + ReByteBuffer trg(getTestDir()); + trg.append("copy_x1.txt"); + ReByteBuffer buffer; + ReDirSync::copyFile(src.str(), 0, -1ll, trg.str(), buffer, ReLogger::globalLogger()); + } void checkRelDate(time_t absTime, int relTime){ int diff = int(time(NULL) - relTime - absTime); if (diff < 0) diff --git a/os/ReDirTools.cpp b/os/ReDirTools.cpp index 75e6afd..5dc5f8e 100644 --- a/os/ReDirTools.cpp +++ b/os/ReDirTools.cpp @@ -1006,7 +1006,7 @@ ReDirSync::ReDirSync() : ReDirOptions(s_syncUsage, s_syncExamples), m_buffer() { - m_buffer.ensureSize(4u*1024*1024*1024); + m_buffer.ensureSize(4u*1024u*1024u); m_programArgs.addBool("add", i18n("copies only files which does not exist on the target"), 'a', "add", false); @@ -1053,6 +1053,7 @@ void ReDirSync::copyFile(ReDirStatus_t* entry, const char* target){ bool ReDirSync::copyFile(const char* source, time_t modified, int64_t size, const char* target, ReByteBuffer& buffer, ReLogger* logger){ bool rc = false; +#ifdef __linux__ if (size < 0ll){ struct stat info; if (stat(source, &info) == 0) @@ -1111,6 +1112,10 @@ bool ReDirSync::copyFile(const char* source, time_t modified, int64_t size, fclose(fpSource); } } +#elif defined __WIN32__ + BOOL dummy; + rc = CopyFileEx(source, target, NULL, NULL, &dummy, COPY_FILE_NO_BUFFERING) != 0; +#endif return rc; } /**