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.
| 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. |
| 490 | bool 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 | |
| 513 | static zipios::ConstEntryPointer findEntry(zipios::ZipFile& zf, const std::string& name) |
| 514 | { |
no test coverage detected