- better signature checking for magic IBSP

pull/25/head
Tai Chi Minh Ralph Eastwood 2013-04-05 13:25:39 +01:00
parent f260fe8e8b
commit 705768e6d9
1 changed files with 15 additions and 4 deletions

View File

@ -171,11 +171,22 @@ Q3BSPFileImporter::~Q3BSPFileImporter()
// Returns true, if the loader can read this.
bool Q3BSPFileImporter::CanRead( const std::string& rFile, IOSystem* pIOHandler, bool checkSig ) const
{
if(!checkSig) {
if(checkSig) {
char signature[5];
std::string expected = "IBSP";
Assimp::IOStream *pStream = pIOHandler.Open(rFile, "r");
if (pStream.Read(signature, 1, 4) == 4) {
signature[4] = '\0';
if (expected == signature) {
delete pStream;
return true;
}
}
delete pStream;
} else {
return SimpleExtensionCheck( rFile, "bsp" );
}
// TODO perhaps add keyword based detection
return false;
}
return false;
}
// ------------------------------------------------------------------------------------------------