misc/physfs/extras/physfslualoader.c
author koda
Tue, 20 Nov 2012 18:51:42 +0100
changeset 8074 768427321cab
parent 8073 5a289ef40fdb
child 8119 257ffa847aa2
permissions -rw-r--r--
thou shall not use system headers for crossplatformness

#include "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;
    }
}

void physfsReaderSetBuffer(void *buffer)
{
    physfsReaderBuffer = buffer;
}