misc/libphyslayer/physfslualoader.c
author S.D.
Fri, 23 Sep 2022 02:45:49 +0300
changeset 15876 1878d95d6e15
parent 13537 ecdf6ce2301e
permissions -rw-r--r--
Add GHC_DYNAMIC cmake option - allows building dynamically-linked haskell object files and executables (needed for some distributions)
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
13537
ecdf6ce2301e Fix warnings about unused params in C code
Wuzzy <Wuzzy2@mail.ru>
parents: 9991
diff changeset
     7
#define UNUSED(x) (void)(x)
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
     8
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
     9
void *physfsReaderBuffer;
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    10
8119
257ffa847aa2 physfs: no carbon depency on osx, add cdecl attributes on extra functions
koda
parents: 8074
diff changeset
    11
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
    12
{
13537
ecdf6ce2301e Fix warnings about unused params in C code
Wuzzy <Wuzzy2@mail.ru>
parents: 9991
diff changeset
    13
    UNUSED(L);
8034
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    14
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    15
    if(PHYSFS_eof(f))
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    16
    {
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    17
        return NULL;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    18
    }
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    19
    else
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    20
    {
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    21
        *size = PHYSFS_readBytes(f, physfsReaderBuffer, BUFSIZE);
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    22
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    23
        if(*size == 0)
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    24
            return NULL;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    25
        else
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    26
            return physfsReaderBuffer;
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    27
    }
fc032c0f7b23 Implement reader in C ffs
unc0rr
parents:
diff changeset
    28
}
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    29
8119
257ffa847aa2 physfs: no carbon depency on osx, add cdecl attributes on extra functions
koda
parents: 8074
diff changeset
    30
PHYSFS_DECL void physfsReaderSetBuffer(void *buffer)
8073
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    31
{
5a289ef40fdb physfs compilation on windows
koda
parents: 8040
diff changeset
    32
    physfsReaderBuffer = buffer;
8074
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
    33
}
768427321cab thou shall not use system headers for crossplatformness
koda
parents: 8073
diff changeset
    34