misc/libphyslayer/physfslualoader.c
author sheepluva
Wed, 27 Apr 2016 16:20:59 +0200
changeset 11749 ac58a063d26a
parent 9991 3858d99476f5
child 13542 ecdf6ce2301e
permissions -rw-r--r--
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
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
9991
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents: 8524
diff changeset
     4
#include "physfscompat.h"
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents: 8524
diff changeset
     5
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     6
#define BUFSIZE 1024
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     7
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
     8
void *physfsReaderBuffer;
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     9
8119
257ffa847aa2 physfs: no carbon depency on osx, add cdecl attributes on extra functions
koda
parents: 8074
diff changeset
    10
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
    11
{
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    12
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    13
    if(PHYSFS_eof(f))
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    14
    {
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    15
        return NULL;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    16
    }
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    17
    else
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    18
    {
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    19
        *size = PHYSFS_readBytes(f, physfsReaderBuffer, BUFSIZE);
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    20
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    21
        if(*size == 0)
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    22
            return NULL;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    23
        else
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    24
            return physfsReaderBuffer;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    25
    }
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    26
}
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    27
8119
257ffa847aa2 physfs: no carbon depency on osx, add cdecl attributes on extra functions
koda
parents: 8074
diff changeset
    28
PHYSFS_DECL void physfsReaderSetBuffer(void *buffer)
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    29
{
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    30
    physfsReaderBuffer = buffer;
8074
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
    31
}
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
    32