From: Hannah von Reth Date: Mon, 14 Dec 2020 11:37:33 +0000 (+0100) Subject: Simplify file comparison X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~446^2~11 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3f873ed2ee4de9b4e676bf53928757de90873f2b;p=nextcloud-desktop.git Simplify file comparison --- diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index 4b68e6728..57452bc67 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -42,22 +42,17 @@ bool FileSystem::fileEquals(const QString &fn1, const QString &fn2) } const int BufferSize = 16 * 1024; - char buffer1[BufferSize]; - char buffer2[BufferSize]; - do { - int r = f1.read(buffer1, BufferSize); - if (f2.read(buffer2, BufferSize) != r) { - // this should normally not happen: the files are supposed to have the same size. + QByteArray buffer1(BufferSize, 0); + QByteArray buffer2(BufferSize, 0); + // the files have the same size, compare all of it + while(!f1.atEnd()){ + f1.read(buffer1.data(), BufferSize); + f2.read(buffer2.data(), BufferSize); + if (buffer1 != buffer2) { return false; } - if (r <= 0) { - return true; - } - if (memcmp(buffer1, buffer2, r) != 0) { - return false; - } - } while (true); - return false; + }; + return true; } time_t FileSystem::getModTime(const QString &filename)