misc/libphyslayer/physfslualoader.c
author koda
Mon, 17 Jun 2013 22:54:17 +0200
branchwebgl
changeset 9201 bcf2f7798ebb
parent 8524 a65e9bcf0a03
child 9991 3858d99476f5
permissions -rw-r--r--
redid FindGLEW in the right way (tm)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8074
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
     1
#include "lua.h"
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
     2
#include "physfs.h"
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     3
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     4
#define BUFSIZE 1024
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     5
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
     6
void *physfsReaderBuffer;
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     7
8119
257ffa847aa2 physfs: no carbon depency on osx, add cdecl attributes on extra functions
koda
parents: 8074
diff changeset
     8
PHYSFS_DECL const char * physfsReader(lua_State *L, PHYSFS_File *f, size_t *size)
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     9
{
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    10
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    11
    if(PHYSFS_eof(f))
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    12
    {
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    13
        return NULL;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    14
    }
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    15
    else
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    16
    {
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    17
        *size = PHYSFS_readBytes(f, physfsReaderBuffer, BUFSIZE);
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    18
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    19
        if(*size == 0)
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    20
            return NULL;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    21
        else
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    22
            return physfsReaderBuffer;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    23
    }
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    24
}
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    25
8119
257ffa847aa2 physfs: no carbon depency on osx, add cdecl attributes on extra functions
koda
parents: 8074
diff changeset
    26
PHYSFS_DECL void physfsReaderSetBuffer(void *buffer)
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    27
{
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    28
    physfsReaderBuffer = buffer;
8074
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
    29
}
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
    30