MCPcopy Create free account
hub / github.com/Kitware/VTK / compareFiles

Function compareFiles

ThirdParty/libxml2/vtklibxml2/runtest.c:358–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358static int compareFiles(const char *r1 /* temp */, const char *r2 /* result */) {
359 int res1, res2, total;
360 int fd1, fd2;
361 char bytes1[4096];
362 char bytes2[4096];
363
364 if (update_results) {
365 fd1 = open(r1, RD_FLAGS);
366 if (fd1 < 0)
367 return(-1);
368 fd2 = open(r2, WR_FLAGS, 0644);
369 if (fd2 < 0) {
370 close(fd1);
371 return(-1);
372 }
373 total = 0;
374 do {
375 res1 = read(fd1, bytes1, 4096);
376 if (res1 <= 0)
377 break;
378 total += res1;
379 res2 = write(fd2, bytes1, res1);
380 if (res2 <= 0 || res2 != res1)
381 break;
382 } while (1);
383 close(fd2);
384 close(fd1);
385 if (total == 0)
386 unlink(r2);
387 return(res1 != 0);
388 }
389
390 fd1 = open(r1, RD_FLAGS);
391 if (fd1 < 0)
392 return(-1);
393 fd2 = open(r2, RD_FLAGS);
394 while (1) {
395 res1 = read(fd1, bytes1, 4096);
396 res2 = fd2 >= 0 ? read(fd2, bytes2, 4096) : 0;
397 if ((res1 != res2) || (res1 < 0)) {
398 close(fd1);
399 if (fd2 >= 0)
400 close(fd2);
401 return(1);
402 }
403 if (res1 == 0)
404 break;
405 if (memcmp(bytes1, bytes2, res1) != 0) {
406 close(fd1);
407 if (fd2 >= 0)
408 close(fd2);
409 return(1);
410 }
411 }
412 close(fd1);
413 if (fd2 >= 0)
414 close(fd2);
415 return(0);

Callers 12

saxParseTestFunction · 0.70
oldParseTestFunction · 0.70
noentParseTestFunction · 0.70
streamProcessTestFunction · 0.70
xpathCommonTestFunction · 0.70
xmlidDocTestFunction · 0.70
uriCommonTestFunction · 0.70
schemasOneTestFunction · 0.70
rngOneTestFunction · 0.70
patternTestFunction · 0.70
regexpTestFunction · 0.70
automataTestFunction · 0.70

Calls 2

closeFunction · 0.85
writeFunction · 0.85

Tested by

no test coverage detected