MCPcopy Create free account
hub / github.com/comaps/comaps / IsEqualFiles

Function IsEqualFiles

libs/coding/internal/file_data.cpp:301–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299}
300
301bool IsEqualFiles(string const & firstFile, string const & secondFile)
302{
303 FileData first(firstFile, FileData::Op::READ);
304 FileData second(secondFile, FileData::Op::READ);
305 if (first.Size() != second.Size())
306 return false;
307
308 size_t constexpr bufSize = READ_FILE_BUFFER_SIZE;
309 vector<char> buf1, buf2;
310 buf1.resize(bufSize);
311 buf2.resize(bufSize);
312 size_t const fileSize = static_cast<size_t>(first.Size());
313 size_t currSize = 0;
314
315 while (currSize < fileSize)
316 {
317 size_t const toRead = min(bufSize, fileSize - currSize);
318
319 first.Read(currSize, &buf1[0], toRead);
320 second.Read(currSize, &buf2[0], toRead);
321
322 if (buf1 != buf2)
323 return false;
324
325 currSize += toRead;
326 }
327
328 return true;
329}
330
331std::vector<uint8_t> ReadFile(std::string const & filePath)
332{

Callers 4

UNIT_TESTFunction · 0.85
CreateAndTestZipFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 3

SizeMethod · 0.45
resizeMethod · 0.45
ReadMethod · 0.45

Tested by 4

UNIT_TESTFunction · 0.68
CreateAndTestZipFunction · 0.68
UNIT_TESTFunction · 0.68