misc/libphysfs/extras/physfslualoader.c
branchphysfslayer
changeset 8524 a65e9bcf0a03
parent 8522 1853628ae285
child 8526 9f2bd885d773
equal deleted inserted replaced
8522:1853628ae285 8524:a65e9bcf0a03
     1 #include "lua.h"
       
     2 #include "physfs.h"
       
     3 
       
     4 #define BUFSIZE 1024
       
     5 
       
     6 void *physfsReaderBuffer;
       
     7 
       
     8 PHYSFS_DECL 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 }
       
    25 
       
    26 PHYSFS_DECL void physfsReaderSetBuffer(void *buffer)
       
    27 {
       
    28     physfsReaderBuffer = buffer;
       
    29 }
       
    30