MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / readRawFile

Method readRawFile

tools/ktx/command_create.cpp:1469–1488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1467}
1468
1469std::string CommandCreate::readRawFile(const std::filesystem::path& filepath) {
1470 std::string result;
1471 InputStream inputStream(filepath.string(), *this);
1472
1473 inputStream->seekg(0, std::ios::end);
1474 if (inputStream->fail())
1475 fatal(rc::IO_FAILURE, "Failed to seek file \"{}\": {}.", filepath.generic_string(), errnoMessage());
1476
1477 const auto size = inputStream->tellg();
1478 inputStream->seekg(0);
1479 if (inputStream->fail())
1480 fatal(rc::IO_FAILURE, "Failed to seek file \"{}\": {}.", filepath.generic_string(), errnoMessage());
1481
1482 result.resize(size);
1483 inputStream->read(result.data(), size);
1484 if (inputStream->fail())
1485 fatal(rc::IO_FAILURE, "Failed to read file \"{}\": {}.", filepath.generic_string(), errnoMessage());
1486
1487 return result;
1488}
1489
1490void CommandCreate::executeCreate() {
1491 const auto warningFn = [this](const std::string& w) { this->warning(w); };

Callers

nothing calls this directly

Calls 6

fatalClass · 0.85
stringMethod · 0.80
errnoMessageFunction · 0.70
resizeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected