MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / zipDataIsValid

Function zipDataIsValid

src/Gui/DocumentRecovery.cpp:490–511  ·  view source on GitHub ↗

Rough check to see if the ZIP data is valid. No CRC calculation, just a fast iteration over the contents to see if it seems basically OK.

Source from the content-addressed store, hash-verified

488/// Rough check to see if the ZIP data is valid. No CRC calculation, just a fast iteration over the
489/// contents to see if it seems basically OK.
490bool zipDataIsValid(const QString& fcstdFile)
491{
492 try {
493 zipios::ZipFile zf(fcstdFile.toStdString());
494 auto entries = zf.entries();
495 int n = 0;
496 for (auto it = entries.begin(); it != entries.end(); ++it) {
497 auto s = zf.getInputStream(*it);
498 if (!s || !(*s)) {
499 return false;
500 }
501 ++n;
502 }
503 if (n == 0) {
504 return false;
505 }
506 return true;
507 }
508 catch (...) {
509 return false;
510 }
511}
512
513static zipios::ConstEntryPointer findEntry(zipios::ZipFile& zf, const std::string& name)
514{

Callers 1

isValidProjectMethod · 0.85

Calls 5

toStdStringMethod · 0.80
entriesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getInputStreamMethod · 0.45

Tested by

no test coverage detected