1
0
Fork 0

(svn r5687) - Cleanup: Some cleanup and commentarizing.

release/0.5
Darkvater 2006-07-31 22:26:11 +00:00
parent 4ba135d9be
commit ec7c9a5fc7
1 changed files with 8 additions and 7 deletions

View File

@ -15,11 +15,11 @@
#define FIO_BUFFER_SIZE 512 #define FIO_BUFFER_SIZE 512
typedef struct { typedef struct {
byte *buffer, *buffer_end; byte *buffer, *buffer_end; ///< position pointer in local buffer and last valid byte of buffer
uint32 pos; uint32 pos; ///< current (system) position in file
FILE *cur_fh; FILE *cur_fh; ///< current file handle
FILE *handles[64]; FILE *handles[64]; ///< array of file handles we can have open
byte buffer_start[512]; byte buffer_start[FIO_BUFFER_SIZE]; ///< local buffer when read from file
} Fio; } Fio;
static Fio _fio; static Fio _fio;
@ -34,7 +34,8 @@ void FioSeekTo(uint32 pos, int mode)
{ {
if (mode == SEEK_CUR) pos += FioGetPos(); if (mode == SEEK_CUR) pos += FioGetPos();
_fio.buffer = _fio.buffer_end = _fio.buffer_start + FIO_BUFFER_SIZE; _fio.buffer = _fio.buffer_end = _fio.buffer_start + FIO_BUFFER_SIZE;
fseek(_fio.cur_fh, (_fio.pos=pos), SEEK_SET); _fio.pos = pos;
fseek(_fio.cur_fh, _fio.pos, SEEK_SET);
} }
// Seek to a file and a position // Seek to a file and a position
@ -43,7 +44,7 @@ void FioSeekToFile(uint32 pos)
FILE *f = _fio.handles[pos >> 24]; FILE *f = _fio.handles[pos >> 24];
assert(f != NULL); assert(f != NULL);
_fio.cur_fh = f; _fio.cur_fh = f;
FioSeekTo(pos & 0xFFFFFF, SEEK_SET); FioSeekTo(GB(pos, 0, 24), SEEK_SET);
} }
byte FioReadByte(void) byte FioReadByte(void)