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

Method TextFileToBuffer

code/Common/BaseImporter.cpp:463–487  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

461
462// ------------------------------------------------------------------------------------------------
463void BaseImporter::TextFileToBuffer(IOStream *stream,
464 std::vector<char> &data,
465 TextFileMode mode) {
466 ai_assert(nullptr != stream);
467
468 const size_t fileSize = stream->FileSize();
469 if (mode == FORBID_EMPTY) {
470 if (!fileSize) {
471 throw DeadlyImportError("File is empty");
472 }
473 }
474
475 data.reserve(fileSize + 1);
476 data.resize(fileSize);
477 if (fileSize > 0) {
478 if (fileSize != stream->Read(&data[0], 1, fileSize)) {
479 throw DeadlyImportError("File read error");
480 }
481
482 ConvertToUTF8(data);
483 }
484
485 // append a binary zero to simplify string parsing
486 data.push_back(0);
487}
488
489// ------------------------------------------------------------------------------------------------
490namespace Assimp {

Callers

nothing calls this directly

Calls 6

DeadlyImportErrorFunction · 0.85
FileSizeMethod · 0.45
reserveMethod · 0.45
resizeMethod · 0.45
ReadMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected