MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / LoadASCIIFromFile

Method LoadASCIIFromFile

external/tinygltf/tiny_gltf.h:6703–6744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6701}
6702
6703bool TinyGLTF::LoadASCIIFromFile(Model *model, std::string *err,
6704 std::string *warn, const std::string &filename,
6705 unsigned int check_sections) {
6706 std::stringstream ss;
6707
6708 if (fs.ReadWholeFile == nullptr) {
6709 // Programmer error, assert() ?
6710 ss << "Failed to read file: " << filename
6711 << ": one or more FS callback not set" << std::endl;
6712 if (err) {
6713 (*err) = ss.str();
6714 }
6715 return false;
6716 }
6717
6718 std::vector<unsigned char> data;
6719 std::string fileerr;
6720 bool fileread = fs.ReadWholeFile(&data, &fileerr, filename, fs.user_data);
6721 if (!fileread) {
6722 ss << "Failed to read file: " << filename << ": " << fileerr << std::endl;
6723 if (err) {
6724 (*err) = ss.str();
6725 }
6726 return false;
6727 }
6728
6729 size_t sz = data.size();
6730 if (sz == 0) {
6731 if (err) {
6732 (*err) = "Empty file.";
6733 }
6734 return false;
6735 }
6736
6737 std::string basedir = GetBaseDir(filename);
6738
6739 bool ret = LoadASCIIFromString(
6740 model, err, warn, reinterpret_cast<const char *>(&data.at(0)),
6741 static_cast<unsigned int>(data.size()), basedir, check_sections);
6742
6743 return ret;
6744}
6745
6746bool TinyGLTF::LoadBinaryFromMemory(Model *model, std::string *err,
6747 std::string *warn,

Callers 1

load_modelFunction · 0.80

Calls 3

GetBaseDirFunction · 0.85
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected