goat3d

view src/chunk.cc @ 23:b59a3650ed51

mac fixes
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 27 Sep 2013 07:20:22 +0300
parents
children 6b651613bd9f
line source
1 #include "goat3d.h"
2 #include "chunk.h"
4 ChunkHeader chunk_header(int id)
5 {
6 ChunkHeader hdr;
7 hdr.id = id;
8 hdr.size = sizeof hdr;
9 return hdr;
10 }
12 bool write_chunk_header(const ChunkHeader *hdr, goat3d_io *io)
13 {
14 io->seek(-hdr->size, SEEK_CUR, io->cls);
15 if(io->write(hdr, sizeof *hdr, io->cls) < (ssize_t)sizeof *hdr) {
16 return false;
17 }
18 return true;
19 }
21 bool read_chunk_header(ChunkHeader *hdr, goat3d_io *io)
22 {
23 if(io->read(hdr, sizeof *hdr, io->cls) < (ssize_t)sizeof *hdr) {
24 return false;
25 }
26 return true;
27 }
29 void skip_chunk(const ChunkHeader *hdr, goat3d_io *io)
30 {
31 io->seek(hdr->size - sizeof *hdr, SEEK_CUR, io->cls);
32 }