MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / ReadFile

Method ReadFile

Engine/lib/assimp/code/Common/Importer.cpp:581–792  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Reads the given file and returns its contents if successful.

Source from the content-addressed store, hash-verified

579// ------------------------------------------------------------------------------------------------
580// Reads the given file and returns its contents if successful.
581const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
582 ai_assert(nullptr != pimpl);
583
584 ASSIMP_BEGIN_EXCEPTION_REGION();
585 const std::string pFile(_pFile);
586
587 // ----------------------------------------------------------------------
588 // Put a large try block around everything to catch all std::exception's
589 // that might be thrown by STL containers or by new().
590 // ImportErrorException's are throw by ourselves and caught elsewhere.
591 //-----------------------------------------------------------------------
592
593 WriteLogOpening(pFile);
594
595#ifdef ASSIMP_CATCH_GLOBAL_EXCEPTIONS
596 try
597#endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS
598 {
599 // Check whether this Importer instance has already loaded
600 // a scene. In this case we need to delete the old one
601 if (pimpl->mScene) {
602
603 ASSIMP_LOG_DEBUG("(Deleting previous scene)");
604 FreeScene();
605 }
606
607 // First check if the file is accessible at all
608 if( !pimpl->mIOHandler->Exists( pFile)) {
609
610 pimpl->mErrorString = "Unable to open file \"" + pFile + "\".";
611 ASSIMP_LOG_ERROR(pimpl->mErrorString);
612 return nullptr;
613 }
614
615 std::unique_ptr<Profiler> profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME, 0) ? new Profiler() : nullptr);
616 if (profiler) {
617 profiler->BeginRegion("total");
618 }
619
620 // Find an worker class which can handle the file extension.
621 // Multiple importers may be able to handle the same extension (.xml!); gather them all.
622 SetPropertyInteger("importerIndex", -1);
623 struct ImporterAndIndex {
624 BaseImporter * importer;
625 unsigned int index;
626 };
627 std::vector<ImporterAndIndex> possibleImporters;
628 for (unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
629
630 // Every importer has a list of supported extensions.
631 std::set<std::string> extensions;
632 pimpl->mImporter[a]->GetExtensionList(extensions);
633
634 // CAUTION: Do not just search for the extension!
635 // GetExtension() returns the part after the *last* dot, but some extensions have dots
636 // inside them, e.g. ogre.mesh.xml. Compare the entire end of the string.
637 for (std::set<std::string>::const_iterator it = extensions.cbegin(); it != extensions.cend(); ++it) {
638

Callers 2

fillGuiTreeViewMethod · 0.45

Calls 15

ASSIMP_stricmpFunction · 0.85
BeginRegionMethod · 0.80
EndRegionMethod · 0.80
HasKeyMethod · 0.80
ExecuteOnSceneMethod · 0.80
ProcessSceneMethod · 0.80
CleanMethod · 0.80
aiStringClass · 0.50
ExistsMethod · 0.45
sizeMethod · 0.45
GetExtensionListMethod · 0.45
cbeginMethod · 0.45

Tested by

no test coverage detected