misc/physfs/extras/physfslualoader.c
author koda
Tue, 20 Nov 2012 18:33:09 +0100
changeset 8073 5a289ef40fdb
parent 8040 448d61778ca7
child 8074 768427321cab
permissions -rw-r--r--
physfs compilation on windows * external calls must always be named * physfs has to be compiled as dll * there shouln't be external variables, implemented a function that sets buffer * physfs extras is now integrated in main physfs * removed physfs extras

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