diff --git a/code/AMF/AMFImporter.cpp b/code/AMF/AMFImporter.cpp index df4324d4d..d93ca54cf 100644 --- a/code/AMF/AMFImporter.cpp +++ b/code/AMF/AMFImporter.cpp @@ -407,7 +407,9 @@ void AMFImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler) std::unique_ptr file(pIOHandler->Open(pFile, "rb")); // Check whether we can read from the file - if(file.get() == NULL) throw DeadlyImportError("Failed to open AMF file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open AMF file " + pFile + "."); + } // generate a XML reader for it std::unique_ptr mIOWrapper(new CIrrXML_IOStreamReader(file.get())); diff --git a/code/BVH/BVHLoader.cpp b/code/BVH/BVHLoader.cpp index 1110754c2..5d335d233 100644 --- a/code/BVH/BVHLoader.cpp +++ b/code/BVH/BVHLoader.cpp @@ -124,12 +124,14 @@ void BVHLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSys // read file into memory std::unique_ptr file( pIOHandler->Open( pFile)); - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open file " + pFile + "."); + } size_t fileSize = file->FileSize(); - if( fileSize == 0) - throw DeadlyImportError( "File is too small."); + if (fileSize == 0) { + throw DeadlyImportError("File is too small."); + } mBuffer.resize( fileSize); file->Read( &mBuffer.front(), 1, fileSize); diff --git a/code/CSM/CSMLoader.cpp b/code/CSM/CSMLoader.cpp index fbabea12e..47563feb1 100644 --- a/code/CSM/CSMLoader.cpp +++ b/code/CSM/CSMLoader.cpp @@ -127,7 +127,7 @@ void CSMImporter::InternReadFile( const std::string& pFile, std::unique_ptr file( pIOHandler->Open( pFile, "rb")); // Check whether we can read from the file - if( file.get() == NULL) { + if( file.get() == nullptr) { throw DeadlyImportError( "Failed to open CSM file " + pFile + "."); } diff --git a/code/HMP/HMPLoader.cpp b/code/HMP/HMPLoader.cpp index 0dea09ee0..45f45d022 100644 --- a/code/HMP/HMPLoader.cpp +++ b/code/HMP/HMPLoader.cpp @@ -122,8 +122,9 @@ void HMPImporter::InternReadFile( const std::string& pFile, std::unique_ptr file(mIOHandler->Open(pFile)); // Check whether we can read from the file - if( file.get() == nullptr) - throw DeadlyImportError( "Failed to open HMP file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open HMP file " + pFile + "."); + } // Check whether the HMP file is large enough to contain // at least the file header diff --git a/code/Irr/IRRMeshLoader.cpp b/code/Irr/IRRMeshLoader.cpp index 13db70e91..d07ff87ea 100644 --- a/code/Irr/IRRMeshLoader.cpp +++ b/code/Irr/IRRMeshLoader.cpp @@ -139,8 +139,9 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, std::unique_ptr file( pIOHandler->Open( pFile)); // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open IRRMESH file " + pFile + ""); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open IRRMESH file " + pFile + "."); + } // Construct the irrXML parser CIrrXML_IOStreamReader st(file.get()); diff --git a/code/LWS/LWSLoader.cpp b/code/LWS/LWSLoader.cpp index 952c3ccbc..d02d24ea3 100644 --- a/code/LWS/LWSLoader.cpp +++ b/code/LWS/LWSLoader.cpp @@ -501,7 +501,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, std::unique_ptr file(pIOHandler->Open(pFile, "rb")); // Check whether we can read from the file - if (file.get() == NULL) { + if (file.get() == nullptr) { throw DeadlyImportError("Failed to open LWS file " + pFile + "."); } diff --git a/code/MD2/MD2Loader.cpp b/code/MD2/MD2Loader.cpp index 473ab99bc..abc5f06ff 100644 --- a/code/MD2/MD2Loader.cpp +++ b/code/MD2/MD2Loader.cpp @@ -221,20 +221,21 @@ void MD2Importer::InternReadFile( const std::string& pFile, std::unique_ptr file( pIOHandler->Open( pFile)); // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open MD2 file " + pFile + ""); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open MD2 file " + pFile + ""); + } // check whether the md3 file is large enough to contain // at least the file header fileSize = (unsigned int)file->FileSize(); - if( fileSize < sizeof(MD2::Header)) - throw DeadlyImportError( "MD2 File is too small"); + if (fileSize < sizeof(MD2::Header)) { + throw DeadlyImportError("MD2 File is too small"); + } std::vector mBuffer2(fileSize); file->Read(&mBuffer2[0], 1, fileSize); mBuffer = &mBuffer2[0]; - m_pcHeader = (BE_NCONST MD2::Header*)mBuffer; #ifdef AI_BUILD_BIG_ENDIAN diff --git a/code/MD3/MD3Loader.cpp b/code/MD3/MD3Loader.cpp index 2051ecdda..28799c0fc 100644 --- a/code/MD3/MD3Loader.cpp +++ b/code/MD3/MD3Loader.cpp @@ -747,8 +747,9 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS std::unique_ptr file( pIOHandler->Open( pFile)); // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open MD3 file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open MD3 file " + pFile + "."); + } // Check whether the md3 file is large enough to contain the header fileSize = (unsigned int)file->FileSize(); diff --git a/code/MD5/MD5Loader.cpp b/code/MD5/MD5Loader.cpp index d428873df..2aa07df18 100644 --- a/code/MD5/MD5Loader.cpp +++ b/code/MD5/MD5Loader.cpp @@ -332,13 +332,12 @@ void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneLis // ------------------------------------------------------------------------------------------------ // Load a MD5MESH file void MD5Importer::LoadMD5MeshFile() { - std::string pFile = mFile + "md5mesh"; - std::unique_ptr file(mIOHandler->Open(pFile, "rb")); + std::string filename = mFile + "md5mesh"; + std::unique_ptr file(mIOHandler->Open(filename, "rb")); // Check whether we can read from the file if (file.get() == nullptr || !file->FileSize()) { - ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + pFile); - return; + throw DeadlyImportError("Failed to open MD5 file " + filename + "."); } bHadMD5Mesh = true; LoadFileIntoMemory(file.get()); @@ -552,9 +551,9 @@ void MD5Importer::LoadMD5AnimFile() { // Check whether we can read from the file if (!file.get() || !file->FileSize()) { - ASSIMP_LOG_WARN("Failed to read MD5ANIM file: " + pFile); - return; + throw DeadlyImportError("Failed to open MD3 file " + file + "."); } + LoadFileIntoMemory(file.get()); // parse the basic file structure diff --git a/code/MDL/HalfLife/HL1MDLLoader.h b/code/MDL/HalfLife/HL1MDLLoader.h index c4293259c..2891ddb1e 100644 --- a/code/MDL/HalfLife/HL1MDLLoader.h +++ b/code/MDL/HalfLife/HL1MDLLoader.h @@ -222,12 +222,14 @@ void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, unsigned std::unique_ptr file(io_->Open(file_path)); - if (file.get() == NULL) + if (file.get() == nullptr) { throw DeadlyImportError("Failed to open MDL file " + DefaultIOSystem::fileName(file_path) + "."); + } const size_t file_size = file->FileSize(); - if (file_size < sizeof(MDLFileHeader)) + if (file_size < sizeof(MDLFileHeader)) { throw DeadlyImportError("MDL file is too small."); + } buffer = new unsigned char[1 + file_size]; file->Read((void *)buffer, 1, file_size); diff --git a/code/Raw/RawLoader.cpp b/code/Raw/RawLoader.cpp index 092323cc0..bb58026f0 100644 --- a/code/Raw/RawLoader.cpp +++ b/code/Raw/RawLoader.cpp @@ -104,7 +104,7 @@ void RAWImporter::InternReadFile( const std::string& pFile, std::unique_ptr file( pIOHandler->Open( pFile, "rb")); // Check whether we can read from the file - if( file.get() == NULL) { + if( file.get() == nullptr) { throw DeadlyImportError( "Failed to open RAW file " + pFile + "."); } diff --git a/code/X/XFileImporter.cpp b/code/X/XFileImporter.cpp index 846023b93..0b256b0bc 100644 --- a/code/X/XFileImporter.cpp +++ b/code/X/XFileImporter.cpp @@ -113,7 +113,7 @@ const aiImporterDesc* XFileImporter::GetInfo () const { void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { // read file into memory std::unique_ptr file( pIOHandler->Open( pFile)); - if ( file.get() == NULL ) { + if ( file.get() == nullptr ) { throw DeadlyImportError( "Failed to open file " + pFile + "." ); } diff --git a/include/assimp/irrXMLWrapper.h b/include/assimp/irrXMLWrapper.h index 65a7be298..52c174791 100644 --- a/include/assimp/irrXMLWrapper.h +++ b/include/assimp/irrXMLWrapper.h @@ -63,7 +63,7 @@ namespace Assimp { * @code * // open the file * std::unique_ptr file( pIOHandler->Open( pFile)); - * if( file.get() == NULL) { + * if( file.get() == nullptr ) { * throw DeadlyImportError( "Failed to open file " + pFile + "."); * } *