mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-07-30 07:44:13 +02:00
Harden EPLAN import: format detection, trim SDK, docs (M4)
- EdzArchive checks the archive magic up front: gives a clear message for zip-format .edz (not yet supported) and unrecognised data, instead of an opaque 7z decode error. - Trim the vendored LZMA SDK headers to the decode closure actually used (removes 21 unused encoder/multithread/Xz/Aes headers; 18 .c + 18 .h remain). - Add sources/import/edz/README.md documenting the feature, the data mapping and the bundled SDK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
@@ -41,6 +42,29 @@ bool EdzArchive::extract(const QString &edz_path)
|
||||
return false;
|
||||
}
|
||||
|
||||
// A .edz is a 7-Zip archive (magic "7z\xBC\xAF\x27\x1C"). Some EPLAN exports
|
||||
// are instead zip-format ("PK\x03\x04"); the bundled reader only does 7z, so
|
||||
// detect that up front and say so clearly rather than failing opaquely.
|
||||
QFile probe(fi.absoluteFilePath());
|
||||
if (!probe.open(QIODevice::ReadOnly)) {
|
||||
m_error = QStringLiteral("Cannot read %1").arg(edz_path);
|
||||
return false;
|
||||
}
|
||||
const QByteArray magic = probe.read(6);
|
||||
probe.close();
|
||||
static const QByteArray k7z("7z\xBC\xAF\x27\x1C", 6);
|
||||
if (!magic.startsWith(k7z)) {
|
||||
if (magic.startsWith(QByteArray("PK\x03\x04", 4))) {
|
||||
m_error = QStringLiteral(
|
||||
"This .edz is a zip-format package, which is not yet "
|
||||
"supported (only 7-Zip .edz files can be imported).");
|
||||
} else {
|
||||
m_error = QStringLiteral(
|
||||
"Not a valid .edz package (unrecognised archive format).");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dir.reset(new QTemporaryDir);
|
||||
if (!m_dir->isValid()) {
|
||||
m_error = QStringLiteral("Could not create a temporary directory: %1")
|
||||
|
||||
Reference in New Issue
Block a user