MCPcopy Create free account
hub / github.com/Kitware/VTK / ValidateGLBFile

Function ValidateGLBFile

IO/Geometry/vtkGLTFUtils.cxx:273–302  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

271
272//------------------------------------------------------------------------------
273bool ValidateGLBFile(const std::string& magic, uint32_t version, uint32_t fileLength,
274 std::vector<vtkGLTFUtils::ChunkInfoType> chunkInfo)
275{
276 // Check header
277 if (magic != "glTF" || version != vtkGLTFUtils::GLBVersion)
278 {
279 return false;
280 }
281 if (chunkInfo.empty())
282 {
283 return false;
284 }
285 // Compute sum of chunk sizes and check that first chunk is json
286 size_t lengthSum = 0;
287 for (size_t chunkNumber = 0; chunkNumber < chunkInfo.size(); chunkNumber++)
288 {
289 if (chunkNumber == 0)
290 {
291 if (chunkInfo[chunkNumber].first != "JSON")
292 {
293 return false;
294 }
295 }
296 lengthSum += chunkInfo[chunkNumber].second;
297 }
298 // Compute total size
299 lengthSum += vtkGLTFUtils::GLBHeaderSize + chunkInfo.size() * vtkGLTFUtils::GLBChunkHeaderSize;
300 // Check for inconsistent chunk sizes
301 return fileLength == lengthSum;
302}
303VTK_ABI_NAMESPACE_END
304}

Callers 1

LoadFileMetaDataMethod · 0.85

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected