Bladeren bron

replace NULL by nullptr on loadFile.

Kim Kulling 5 jaren geleden
bovenliggende
commit
6397bfbf90

+ 3 - 1
code/AMF/AMFImporter.cpp

@@ -407,7 +407,9 @@ void AMFImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
     std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
     std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
 
 
 	// Check whether we can read from the file
 	// 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
 	// generate a XML reader for it
 	std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
 	std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));

+ 6 - 4
code/BVH/BVHLoader.cpp

@@ -124,12 +124,14 @@ void BVHLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSys
 
 
     // read file into memory
     // read file into memory
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
     std::unique_ptr<IOStream> 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();
     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);
     mBuffer.resize( fileSize);
     file->Read( &mBuffer.front(), 1, fileSize);
     file->Read( &mBuffer.front(), 1, fileSize);

+ 1 - 1
code/CSM/CSMLoader.cpp

@@ -127,7 +127,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
 
 
     // Check whether we can read from the file
     // Check whether we can read from the file
-    if( file.get() == NULL) {
+    if( file.get() == nullptr) {
         throw DeadlyImportError( "Failed to open CSM file " + pFile + ".");
         throw DeadlyImportError( "Failed to open CSM file " + pFile + ".");
     }
     }
 
 

+ 3 - 2
code/HMP/HMPLoader.cpp

@@ -122,8 +122,9 @@ void HMPImporter::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file(mIOHandler->Open(pFile));
     std::unique_ptr<IOStream> file(mIOHandler->Open(pFile));
 
 
     // Check whether we can read from the file
     // 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
     // Check whether the HMP file is large enough to contain
     // at least the file header
     // at least the file header

+ 3 - 2
code/Irr/IRRMeshLoader.cpp

@@ -139,8 +139,9 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
 
 
     // Check whether we can read from the file
     // 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
     // Construct the irrXML parser
     CIrrXML_IOStreamReader st(file.get());
     CIrrXML_IOStreamReader st(file.get());

+ 1 - 1
code/LWS/LWSLoader.cpp

@@ -501,7 +501,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene,
     std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
     std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
 
 
     // Check whether we can read from the file
     // Check whether we can read from the file
-    if (file.get() == NULL) {
+    if (file.get() == nullptr) {
         throw DeadlyImportError("Failed to open LWS file " + pFile + ".");
         throw DeadlyImportError("Failed to open LWS file " + pFile + ".");
     }
     }
 
 

+ 6 - 5
code/MD2/MD2Loader.cpp

@@ -221,20 +221,21 @@ void MD2Importer::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
 
 
     // Check whether we can read from the file
     // 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
     // check whether the md3 file is large enough to contain
     // at least the file header
     // at least the file header
     fileSize = (unsigned int)file->FileSize();
     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<uint8_t> mBuffer2(fileSize);
     std::vector<uint8_t> mBuffer2(fileSize);
     file->Read(&mBuffer2[0], 1, fileSize);
     file->Read(&mBuffer2[0], 1, fileSize);
     mBuffer = &mBuffer2[0];
     mBuffer = &mBuffer2[0];
 
 
-
     m_pcHeader = (BE_NCONST MD2::Header*)mBuffer;
     m_pcHeader = (BE_NCONST MD2::Header*)mBuffer;
 
 
 #ifdef AI_BUILD_BIG_ENDIAN
 #ifdef AI_BUILD_BIG_ENDIAN

+ 3 - 2
code/MD3/MD3Loader.cpp

@@ -747,8 +747,9 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
 
 
     // Check whether we can read from the file
     // 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
     // Check whether the md3 file is large enough to contain the header
     fileSize = (unsigned int)file->FileSize();
     fileSize = (unsigned int)file->FileSize();

+ 5 - 6
code/MD5/MD5Loader.cpp

@@ -332,13 +332,12 @@ void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneLis
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Load a MD5MESH file
 // Load a MD5MESH file
 void MD5Importer::LoadMD5MeshFile() {
 void MD5Importer::LoadMD5MeshFile() {
-    std::string pFile = mFile + "md5mesh";
-    std::unique_ptr<IOStream> file(mIOHandler->Open(pFile, "rb"));
+    std::string filename = mFile + "md5mesh";
+    std::unique_ptr<IOStream> file(mIOHandler->Open(filename, "rb"));
 
 
     // Check whether we can read from the file
     // Check whether we can read from the file
     if (file.get() == nullptr || !file->FileSize()) {
     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;
     bHadMD5Mesh = true;
     LoadFileIntoMemory(file.get());
     LoadFileIntoMemory(file.get());
@@ -552,9 +551,9 @@ void MD5Importer::LoadMD5AnimFile() {
 
 
     // Check whether we can read from the file
     // Check whether we can read from the file
     if (!file.get() || !file->FileSize()) {
     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());
     LoadFileIntoMemory(file.get());
 
 
     // parse the basic file structure
     // parse the basic file structure

+ 4 - 2
code/MDL/HalfLife/HL1MDLLoader.h

@@ -222,12 +222,14 @@ void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, unsigned
 
 
     std::unique_ptr<IOStream> file(io_->Open(file_path));
     std::unique_ptr<IOStream> file(io_->Open(file_path));
 
 
-    if (file.get() == NULL)
+    if (file.get() == nullptr) {
         throw DeadlyImportError("Failed to open MDL file " + DefaultIOSystem::fileName(file_path) + ".");
         throw DeadlyImportError("Failed to open MDL file " + DefaultIOSystem::fileName(file_path) + ".");
+    }
 
 
     const size_t file_size = file->FileSize();
     const size_t file_size = file->FileSize();
-    if (file_size < sizeof(MDLFileHeader))
+    if (file_size < sizeof(MDLFileHeader)) {
         throw DeadlyImportError("MDL file is too small.");
         throw DeadlyImportError("MDL file is too small.");
+    }
 
 
     buffer = new unsigned char[1 + file_size];
     buffer = new unsigned char[1 + file_size];
     file->Read((void *)buffer, 1, file_size);
     file->Read((void *)buffer, 1, file_size);

+ 1 - 1
code/Raw/RawLoader.cpp

@@ -104,7 +104,7 @@ void RAWImporter::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
 
 
     // Check whether we can read from the file
     // Check whether we can read from the file
-    if( file.get() == NULL) {
+    if( file.get() == nullptr) {
         throw DeadlyImportError( "Failed to open RAW file " + pFile + ".");
         throw DeadlyImportError( "Failed to open RAW file " + pFile + ".");
     }
     }
 
 

+ 1 - 1
code/X/XFileImporter.cpp

@@ -113,7 +113,7 @@ const aiImporterDesc* XFileImporter::GetInfo () const {
 void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
 void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
     // read file into memory
     // read file into memory
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
-    if ( file.get() == NULL ) {
+    if ( file.get() == nullptr ) {
         throw DeadlyImportError( "Failed to open file " + pFile + "." );
         throw DeadlyImportError( "Failed to open file " + pFile + "." );
     }
     }
 
 

+ 1 - 1
include/assimp/irrXMLWrapper.h

@@ -63,7 +63,7 @@ namespace Assimp    {
  *  @code
  *  @code
  * // open the file
  * // open the file
  * std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
  * std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
- * if( file.get() == NULL) {
+ * if( file.get() == nullptr ) {
  *    throw DeadlyImportError( "Failed to open file " + pFile + ".");
  *    throw DeadlyImportError( "Failed to open file " + pFile + ".");
  * }
  * }
  *
  *