fix CanRead-method for the 3MF-Importer.
parent
c5c0052a6c
commit
f11d4902c6
|
@ -414,6 +414,9 @@ bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bo
|
||||||
if ( nullptr == pIOHandler ) {
|
if ( nullptr == pIOHandler ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ( !D3MF::D3MFOpcPackage::isZipArchive( pIOHandler, filename ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
D3MF::D3MFOpcPackage opcPackage( pIOHandler, filename );
|
D3MF::D3MFOpcPackage opcPackage( pIOHandler, filename );
|
||||||
return opcPackage.validate();
|
return opcPackage.validate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,6 +499,15 @@ bool D3MFOpcPackage::validate() {
|
||||||
return mZipArchive->Exists( ModelRef.c_str() );
|
return mZipArchive->Exists( ModelRef.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool D3MFOpcPackage::isZipArchive( IOSystem* pIOHandler, const std::string& rFile ) {
|
||||||
|
D3MF::D3MFZipArchive ar( pIOHandler, rFile );
|
||||||
|
if ( !ar.isOpen() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream* stream) {
|
std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream* stream) {
|
||||||
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(stream));
|
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(stream));
|
||||||
std::unique_ptr<XmlReader> xml(irr::io::createIrrXMLReader(xmlStream.get()));
|
std::unique_ptr<XmlReader> xml(irr::io::createIrrXMLReader(xmlStream.get()));
|
||||||
|
|
|
@ -64,10 +64,11 @@ class D3MFZipArchive;
|
||||||
|
|
||||||
class D3MFOpcPackage {
|
class D3MFOpcPackage {
|
||||||
public:
|
public:
|
||||||
D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile);
|
D3MFOpcPackage( IOSystem* pIOHandler, const std::string& rFile );
|
||||||
~D3MFOpcPackage();
|
~D3MFOpcPackage();
|
||||||
IOStream* RootStream() const;
|
IOStream* RootStream() const;
|
||||||
bool validate();
|
bool validate();
|
||||||
|
static bool isZipArchive( IOSystem* pIOHandler, const std::string& rFile );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string ReadPackageRootRelationship(IOStream* stream);
|
std::string ReadPackageRootRelationship(IOStream* stream);
|
||||||
|
|
Loading…
Reference in New Issue