summaryrefslogtreecommitdiff
path: root/lib/binary.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:22:55 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:22:55 +0200
commitc4182431ac7d9d306fdd2267e082fa4cec6fec2c (patch)
tree865cca543c062b7af2586f85cee19f9af4e7614d /lib/binary.cpp
parent5.11 (diff)
downloadFreeFileSync-c4182431ac7d9d306fdd2267e082fa4cec6fec2c.tar.gz
FreeFileSync-c4182431ac7d9d306fdd2267e082fa4cec6fec2c.tar.bz2
FreeFileSync-c4182431ac7d9d306fdd2267e082fa4cec6fec2c.zip
5.12
Diffstat (limited to 'lib/binary.cpp')
-rw-r--r--lib/binary.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/binary.cpp b/lib/binary.cpp
index 10994cc9..4ef30c15 100644
--- a/lib/binary.cpp
+++ b/lib/binary.cpp
@@ -85,7 +85,6 @@ bool zen::filesHaveSameContent(const Zstring& filename1, const Zstring& filename
FileInput file2(filename2); //
BufferSize bufferSize;
- UInt64 bytesCompared;
TickVal lastDelayViolation = getTicks();
@@ -96,14 +95,19 @@ bool zen::filesHaveSameContent(const Zstring& filename1, const Zstring& filename
const TickVal startTime = getTicks();
- const size_t length1 = file1.read(&memory1[0], bufferSize); //returns actual number of bytes read; throw FileError()
- const size_t length2 = file2.read(&memory2[0], bufferSize); //
+ const size_t length1 = file1.read(&memory1[0], bufferSize); //throw FileError()
+ const size_t length2 = file2.read(&memory2[0], bufferSize); //returns actual number of bytes read
+ //send progress updates immediately after reading to reliably allow speed calculations for our clients!
+ callback.updateCompareStatus(to<Int64>(std::max(length1, length2)));
- const TickVal now = getTicks();
+ if (length1 != length2 || ::memcmp(&memory1[0], &memory2[0], length1) != 0)
+ return false;
//-------- dynamically set buffer size to keep callback interval between 100 - 500ms ---------------------
if (TICKS_PER_SEC > 0)
{
+ const TickVal now = getTicks();
+
const std::int64_t loopTime = dist(startTime, now) * 1000 / TICKS_PER_SEC; //unit: [ms]
if (loopTime < 100)
{
@@ -120,12 +124,6 @@ bool zen::filesHaveSameContent(const Zstring& filename1, const Zstring& filename
}
}
//------------------------------------------------------------------------------------------------
-
- if (length1 != length2 || ::memcmp(&memory1[0], &memory2[0], length1) != 0)
- return false;
-
- bytesCompared += length1;
- callback.updateCompareStatus(bytesCompared); //send progress updates
}
while (!file1.eof());
bgstack15