| 522 | } |
| 523 | |
| 524 | bool xmlFilesAreValid(const QString& fcstdFile) |
| 525 | { |
| 526 | try { |
| 527 | zipios::ZipFile zf(fcstdFile.toStdString()); |
| 528 | auto doc = findEntry(zf, "Document.xml"); |
| 529 | if (!doc) { |
| 530 | return false; |
| 531 | } |
| 532 | { |
| 533 | auto s = zf.getInputStream(doc); |
| 534 | QByteArray bytes; |
| 535 | bytes.resize(0); |
| 536 | std::string tmp((std::istreambuf_iterator<char>(*s)), std::istreambuf_iterator<char>()); |
| 537 | QXmlStreamReader xr(QByteArray(tmp.data(), int(tmp.size()))); |
| 538 | while (!xr.atEnd()) { |
| 539 | xr.readNext(); |
| 540 | } |
| 541 | if (xr.hasError()) { |
| 542 | return false; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | // GuiDocument.xml is optional, but if it's present it must be well-formed |
| 547 | if (auto gui = findEntry(zf, "GuiDocument.xml")) { |
| 548 | auto s = zf.getInputStream(gui); |
| 549 | std::string tmp((std::istreambuf_iterator<char>(*s)), std::istreambuf_iterator<char>()); |
| 550 | QXmlStreamReader xr(QByteArray(tmp.data(), int(tmp.size()))); |
| 551 | while (!xr.atEnd()) { |
| 552 | xr.readNext(); |
| 553 | } |
| 554 | if (xr.hasError()) { |
| 555 | return false; |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | return true; |
| 560 | } |
| 561 | catch (...) { |
| 562 | return false; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | bool DocumentRecoveryPrivate::isValidProject(const QFileInfo& fi) const |
| 567 | { |
no test coverage detected