From 6a5fa78ebb1178d97d18ea533f3be0a700667511 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 4 Jan 2009 13:43:54 +0000 Subject: Move stream comparison code out of BackupQueries::Compare to FileStream class. --- bin/bbackupquery/BackupQueries.cpp | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'bin/bbackupquery/BackupQueries.cpp') diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index 85f659d4..c63b964a 100644 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -1728,34 +1728,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, SelfFlushingStream flushFile(*fileOnServerStream); // Open the local file FileStream l(localPath.c_str()); - - // Size - IOStream::pos_type fileSizeLocal = l.BytesLeftToRead(); - IOStream::pos_type fileSizeServer = 0; - - // Test the contents - char buf1[2048]; - char buf2[2048]; - while(fileOnServerStream->StreamDataLeft() && l.StreamDataLeft()) - { - int size = fileOnServerStream->Read(buf1, sizeof(buf1), mrConnection.GetTimeout()); - fileSizeServer += size; - - if(l.Read(buf2, size) != size - || ::memcmp(buf1, buf2, size) != 0) - { - equal = false; - break; - } - } - - // Check read all the data from the server and file -- can't be equal if local and remote aren't the same length - // Can't use StreamDataLeft() test on file, because if it's the same size, it won't know - // it's EOF yet. - if(fileOnServerStream->StreamDataLeft() || fileSizeServer != fileSizeLocal) - { - equal = false; - } + equal = l.CompareWith(fileOnServerStream, mrConnection.GetTimeout()); } } -- cgit v1.2.3