misc/physfs/extras/physfslualoader.c
author unc0rr
Sat, 17 Nov 2012 00:01:06 +0400
branchphysfslayer
changeset 8034 fc032c0f7b23
child 8040 448d61778ca7
permissions -rw-r--r--
Implement reader in C ffs

#include <lua51/lua.h>
#include <physfs.h>

#define BUFSIZE 1024

void * physfsReaderBuffer;

const char * physfsReader(lua_State *L, PHYSFS_File *f, size_t *size)
{

    if(PHYSFS_eof(f))
    {
        return NULL;
    }
    else
    {
        *size = PHYSFS_readBytes(f, physfsReaderBuffer, BUFSIZE);

        if(*size == 0)
            return NULL;
        else
            return physfsReaderBuffer;
    }
}