------------------------------------------------------------------------------------------------
| 461 | |
| 462 | // ------------------------------------------------------------------------------------------------ |
| 463 | void 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 | // ------------------------------------------------------------------------------------------------ |
| 490 | namespace Assimp { |