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

Method executeInfo

tools/ktx/command_info.cpp:111–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void CommandInfo::executeInfo() {
112 InputStream inputStream(options.inputFilepath, *this);
113
114 KTX_error_code result;
115 bool v2 = true;
116
117 ktx_uint8_t ktx_ident_ref[12] = KTX_IDENTIFIER_REF;
118 ktx_uint8_t identifier[12] = {};
119 inputStream->read((char*)identifier, 12);
120 inputStream->clear(); // Clear an unexpected EOF so seekg works.
121 inputStream->seekg(0); // Rewind to give validation a clean slate.
122 if (!memcmp(identifier, ktx_ident_ref, 12)) {
123 if (options.format != OutputFormat::text)
124 fatal_usage("JSON output formats are not supported for KTX v1 files.");
125 v2 = false;
126 StreambufStream<std::streambuf*> ktxStream{inputStream->rdbuf(), std::ios::in | std::ios::binary};
127 result = ktxPrintKTX1InfoTextForStream(ktxStream.stream());
128 } else {
129 switch (options.format) {
130 case OutputFormat::text:
131 result = printInfoText(inputStream);
132 break;
133 case OutputFormat::json:
134 result = printInfoJSON(inputStream, false);
135 break;
136 case OutputFormat::json_mini:
137 result = printInfoJSON(inputStream, true);
138 break;
139 default:
140 assert(false && "Internal error");
141 return;
142 }
143 }
144
145 if (result != KTX_SUCCESS)
146 fatal(rc::INVALID_FILE, "Failed to process KTX {} file \"{}\": {}",
147 v2 ? "v2" : "v1",
148 fmtInFile(options.inputFilepath), ktxErrorString(result));
149}
150
151KTX_error_code CommandInfo::printInfoText(std::istream& file) {
152 std::ostringstream messagesOS;

Callers

nothing calls this directly

Calls 8

assertFunction · 0.85
fatalClass · 0.85
fmtInFileFunction · 0.85
ktxErrorStringFunction · 0.85
readMethod · 0.45
clearMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected