author | koda |
Tue, 20 Nov 2012 18:33:09 +0100 | |
changeset 8073 | 5a289ef40fdb |
parent 8040 | 448d61778ca7 |
child 8074 | 768427321cab |
permissions | -rw-r--r-- |
8040 | 1 |
#include <lua.h> |
8034 | 2 |
#include <physfs.h> |
3 |
||
4 |
#define BUFSIZE 1024 |
|
5 |
||
8073 | 6 |
void *physfsReaderBuffer; |
8034 | 7 |
|
8 |
const char * physfsReader(lua_State *L, PHYSFS_File *f, size_t *size) |
|
9 |
{ |
|
10 |
||
11 |
if(PHYSFS_eof(f)) |
|
12 |
{ |
|
13 |
return NULL; |
|
14 |
} |
|
15 |
else |
|
16 |
{ |
|
17 |
*size = PHYSFS_readBytes(f, physfsReaderBuffer, BUFSIZE); |
|
18 |
||
19 |
if(*size == 0) |
|
20 |
return NULL; |
|
21 |
else |
|
22 |
return physfsReaderBuffer; |
|
23 |
} |
|
24 |
} |
|
8073 | 25 |
|
26 |
void physfsReaderSetBuffer(void *buffer) |
|
27 |
{ |
|
28 |
physfsReaderBuffer = buffer; |
|
29 |
} |