goat3d

annotate src/chunk.cc @ 51:fa5c52ea9d59

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 17 Jan 2014 18:16:09 +0200
parents 6b651613bd9f
children dad392c710df
rev   line source
nuclear@13 1 #include "goat3d.h"
nuclear@13 2 #include "chunk.h"
nuclear@13 3
nuclear@47 4 using namespace g3dimpl;
nuclear@47 5
nuclear@13 6 ChunkHeader chunk_header(int id)
nuclear@13 7 {
nuclear@13 8 ChunkHeader hdr;
nuclear@13 9 hdr.id = id;
nuclear@13 10 hdr.size = sizeof hdr;
nuclear@13 11 return hdr;
nuclear@13 12 }
nuclear@13 13
nuclear@47 14 bool g3dimpl::write_chunk_header(const ChunkHeader *hdr, goat3d_io *io)
nuclear@13 15 {
nuclear@24 16 io->seek(-(long)hdr->size, SEEK_CUR, io->cls);
nuclear@24 17 if(io->write(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
nuclear@13 18 return false;
nuclear@13 19 }
nuclear@13 20 return true;
nuclear@13 21 }
nuclear@13 22
nuclear@47 23 bool g3dimpl::read_chunk_header(ChunkHeader *hdr, goat3d_io *io)
nuclear@13 24 {
nuclear@24 25 if(io->read(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
nuclear@13 26 return false;
nuclear@13 27 }
nuclear@13 28 return true;
nuclear@13 29 }
nuclear@13 30
nuclear@47 31 void g3dimpl::skip_chunk(const ChunkHeader *hdr, goat3d_io *io)
nuclear@13 32 {
nuclear@13 33 io->seek(hdr->size - sizeof *hdr, SEEK_CUR, io->cls);
nuclear@13 34 }