MCPcopy Create free account
hub / github.com/assimp/assimp / ReadFileFromMemory

Method ReadFileFromMemory

code/Common/Importer.cpp:485–523  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

483
484// ------------------------------------------------------------------------------------------------
485const aiScene* Importer::ReadFileFromMemory(const void* pBuffer, size_t pLength, unsigned int pFlags, const char* pHint ) {
486 ai_assert(nullptr != pimpl);
487
488 IOSystem* io = pimpl->mIOHandler;
489 try {
490 if (pHint == nullptr) {
491 pHint = "";
492 }
493 if (!pBuffer || !pLength || strlen(pHint) > MaxLenHint ) {
494 pimpl->mErrorString = "Invalid parameters passed to ReadFileFromMemory()";
495 return nullptr;
496 }
497 // prevent deletion of the previous IOHandler
498 pimpl->mIOHandler = nullptr;
499
500 SetIOHandler(new MemoryIOSystem((const uint8_t*)pBuffer,pLength,io));
501
502 // read the file and recover the previous IOSystem
503 static const size_t BufSize(Importer::MaxLenHint + 28);
504 char fbuff[BufSize];
505 ai_snprintf(fbuff, BufSize, "%s.%s",AI_MEMORYIO_MAGIC_FILENAME,pHint);
506
507 ReadFile(fbuff,pFlags);
508 SetIOHandler(io);
509 } catch(const DeadlyImportError &e) {
510 pimpl->mErrorString = e.what();
511 pimpl->mException = std::current_exception();
512 SetIOHandler(io);
513 return ExceptionSwallower<const aiScene*>()(); \
514 } catch(...) {
515 pimpl->mErrorString = "Unknown exception";
516 pimpl->mException = std::current_exception();
517 SetIOHandler(io);
518 return ExceptionSwallower<const aiScene*>()(); \
519
520 }
521
522 return pimpl->mScene;
523}
524
525// ------------------------------------------------------------------------------------------------
526void WriteLogOpening(const std::string& file) {

Callers 15

TEST_FFunction · 0.80
TEST_FFunction · 0.80
TEST_FFunction · 0.80
TEST_FFunction · 0.80
TEST_FFunction · 0.80
TEST_FFunction · 0.80
TESTFunction · 0.80
LLVMFuzzerTestOneInputFunction · 0.80
LLVMFuzzerTestOneInputFunction · 0.80
LLVMFuzzerTestOneInputFunction · 0.80
LLVMFuzzerTestOneInputFunction · 0.80
LLVMFuzzerTestOneInputFunction · 0.80

Calls 3

ai_snprintfFunction · 0.85
ReadFileFunction · 0.50
whatMethod · 0.45

Tested by

no test coverage detected