Updates to GFILE code
This commit is contained in:
parent
1d904dccaf
commit
a86bab4a77
7 changed files with 90 additions and 85 deletions
|
@ -31,48 +31,11 @@
|
||||||
* @brief A file pointer
|
* @brief A file pointer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct GFILE {
|
#ifndef GFILE_IMPLEMENTATION
|
||||||
const struct GFILEVMT * vmt;
|
typedef void GFILE;
|
||||||
uint16_t flags;
|
#else
|
||||||
#define GFILEFLG_OPEN 0x0001 // File is open
|
typedef struct GFILE GFILE;
|
||||||
#define GFILEFLG_READ 0x0002 // Read the file
|
#endif
|
||||||
#define GFILEFLG_WRITE 0x0004 // Write the file
|
|
||||||
#define GFILEFLG_APPEND 0x0008 // Append on each write
|
|
||||||
#define GFILEFLG_BINARY 0x0010 // Treat as a binary file
|
|
||||||
#define GFILEFLG_DELONCLOSE 0x0020 // Delete on close
|
|
||||||
#define GFILEFLG_CANSEEK 0x0040 // Seek operations are valid
|
|
||||||
#define GFILEFLG_FAILONBLOCK 0x0080 // Fail on a blocking call
|
|
||||||
#define GFILEFLG_MUSTEXIST 0x0100 // On open file must exist
|
|
||||||
#define GFILEFLG_MUSTNOTEXIST 0x0200 // On open file must not exist
|
|
||||||
#define GFILEFLG_TRUNC 0x0400 // On open truncate the file
|
|
||||||
void * obj;
|
|
||||||
long int pos;
|
|
||||||
} GFILE;
|
|
||||||
|
|
||||||
typedef struct GFILEVMT {
|
|
||||||
const struct GFILEVMT * next;
|
|
||||||
uint8_t flags;
|
|
||||||
#define GFSFLG_WRITEABLE 0x0001
|
|
||||||
#define GFSFLG_CASESENSITIVE 0x0002
|
|
||||||
#define GFSFLG_SEEKABLE 0x0004
|
|
||||||
#define GFSFLG_FAST 0x0010
|
|
||||||
#define GFSFLG_SMALL 0x0020
|
|
||||||
#define GFSFLG_TEXTMODES 0x0040
|
|
||||||
char prefix;
|
|
||||||
bool_t del(const char *fname);
|
|
||||||
bool_t exists(const char *fname);
|
|
||||||
long int filesize(const char *fname);
|
|
||||||
bool_t ren(const char *oldname, const char *newname);
|
|
||||||
bool_t open(GFILE *f, const char *fname);
|
|
||||||
void close(GFILE *f);
|
|
||||||
int read(GFILE *f, char *buf, int size);
|
|
||||||
int write(GFILE *f, const char *buf, int size);
|
|
||||||
bool_t setpos(GFILE *f, long int pos);
|
|
||||||
long int getsize(GFILE *f);
|
|
||||||
bool_t eof(GFILE *f);
|
|
||||||
} GFILEVMT;
|
|
||||||
|
|
||||||
typedef void GFILE;
|
|
||||||
|
|
||||||
extern GFILE *gfileStdIn;
|
extern GFILE *gfileStdIn;
|
||||||
extern GFILE *gfileStdErr;
|
extern GFILE *gfileStdErr;
|
||||||
|
@ -92,8 +55,8 @@ extern "C" {
|
||||||
bool_t gfileRename(const char *oldname, const char *newname);
|
bool_t gfileRename(const char *oldname, const char *newname);
|
||||||
GFILE * gfileOpen(const char *fname, const char *mode);
|
GFILE * gfileOpen(const char *fname, const char *mode);
|
||||||
void gfileClose(GFILE *f);
|
void gfileClose(GFILE *f);
|
||||||
size_t gfileRead(GFILE *f, char *buf, size_t len);
|
size_t gfileRead(GFILE *f, void *buf, size_t len);
|
||||||
size_t gfileWrite(GFILE *f, const char *buf, size_t len);
|
size_t gfileWrite(GFILE *f, const void *buf, size_t len);
|
||||||
long int gfileGetPos(GFILE *f);
|
long int gfileGetPos(GFILE *f);
|
||||||
bool_t gfileSetPos(GFILE *f, long int pos);
|
bool_t gfileSetPos(GFILE *f, long int pos);
|
||||||
long int gfileGetSize(GFILE *f);
|
long int gfileGetSize(GFILE *f);
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
* Include the sub-system header files
|
* Include the sub-system header files
|
||||||
*/
|
*/
|
||||||
#include "gos/gos.h"
|
#include "gos/gos.h"
|
||||||
#include "gfile/options.h"
|
#include "gfile/gfile.h"
|
||||||
#include "gmisc/gmisc.h"
|
#include "gmisc/gmisc.h"
|
||||||
#include "gqueue/gqueue.h"
|
#include "gqueue/gqueue.h"
|
||||||
#include "gevent/gevent.h"
|
#include "gevent/gevent.h"
|
||||||
|
|
|
@ -12,10 +12,52 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GFILE_IMPLEMENTATION
|
#define GFILE_IMPLEMENTATION
|
||||||
|
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
#if GFX_USE_GFILE
|
#if GFX_USE_GFILE
|
||||||
|
|
||||||
|
struct GFILE {
|
||||||
|
const struct GFILEVMT * vmt;
|
||||||
|
uint16_t flags;
|
||||||
|
#define GFILEFLG_OPEN 0x0001 // File is open
|
||||||
|
#define GFILEFLG_READ 0x0002 // Read the file
|
||||||
|
#define GFILEFLG_WRITE 0x0004 // Write the file
|
||||||
|
#define GFILEFLG_APPEND 0x0008 // Append on each write
|
||||||
|
#define GFILEFLG_BINARY 0x0010 // Treat as a binary file
|
||||||
|
#define GFILEFLG_DELONCLOSE 0x0020 // Delete on close
|
||||||
|
#define GFILEFLG_CANSEEK 0x0040 // Seek operations are valid
|
||||||
|
#define GFILEFLG_FAILONBLOCK 0x0080 // Fail on a blocking call
|
||||||
|
#define GFILEFLG_MUSTEXIST 0x0100 // On open file must exist
|
||||||
|
#define GFILEFLG_MUSTNOTEXIST 0x0200 // On open file must not exist
|
||||||
|
#define GFILEFLG_TRUNC 0x0400 // On open truncate the file
|
||||||
|
void * obj;
|
||||||
|
long int pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct GFILEVMT {
|
||||||
|
const struct GFILEVMT * next;
|
||||||
|
uint8_t flags;
|
||||||
|
#define GFSFLG_WRITEABLE 0x0001
|
||||||
|
#define GFSFLG_CASESENSITIVE 0x0002
|
||||||
|
#define GFSFLG_SEEKABLE 0x0004
|
||||||
|
#define GFSFLG_FAST 0x0010
|
||||||
|
#define GFSFLG_SMALL 0x0020
|
||||||
|
#define GFSFLG_TEXTMODES 0x0040
|
||||||
|
char prefix;
|
||||||
|
bool_t (*del) (const char *fname);
|
||||||
|
bool_t (*exists) (const char *fname);
|
||||||
|
long int (*filesize) (const char *fname);
|
||||||
|
bool_t (*ren) (const char *oldname, const char *newname);
|
||||||
|
bool_t (*open) (GFILE *f, const char *fname);
|
||||||
|
void (*close) (GFILE *f);
|
||||||
|
int (*read) (GFILE *f, void *buf, int size);
|
||||||
|
int (*write) (GFILE *f, const void *buf, int size);
|
||||||
|
bool_t (*setpos) (GFILE *f, long int pos);
|
||||||
|
long int (*getsize) (GFILE *f);
|
||||||
|
bool_t (*eof) (GFILE *f);
|
||||||
|
} GFILEVMT;
|
||||||
|
|
||||||
// The chain of FileSystems
|
// The chain of FileSystems
|
||||||
#define GFILE_CHAINHEAD 0
|
#define GFILE_CHAINHEAD 0
|
||||||
|
|
||||||
|
@ -254,7 +296,6 @@ static bool_t testopen(const GFILEVMT *p, GFILE *f, const char *fname) {
|
||||||
|
|
||||||
// File is open - fill in all the details
|
// File is open - fill in all the details
|
||||||
f->vmt = p;
|
f->vmt = p;
|
||||||
f->err = 0;
|
|
||||||
f->pos = 0;
|
f->pos = 0;
|
||||||
f->flags |= GFILEFLG_OPEN;
|
f->flags |= GFILEFLG_OPEN;
|
||||||
if (p->flags & GFSFLG_SEEKABLE)
|
if (p->flags & GFSFLG_SEEKABLE)
|
||||||
|
@ -269,7 +310,7 @@ GFILE *gfileOpen(const char *fname, const char *mode) {
|
||||||
|
|
||||||
// Get the requested mode
|
// Get the requested mode
|
||||||
if (!(flags = mode2flags(mode)))
|
if (!(flags = mode2flags(mode)))
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
#if GFILE_ALLOW_DEVICESPECIFIC
|
#if GFILE_ALLOW_DEVICESPECIFIC
|
||||||
if (fname[0] && fname[1] == '|') {
|
if (fname[0] && fname[1] == '|') {
|
||||||
|
@ -280,7 +321,7 @@ GFILE *gfileOpen(const char *fname, const char *mode) {
|
||||||
f->flags = flags;
|
f->flags = flags;
|
||||||
for(p = FsChain; p; p = p->next) {
|
for(p = FsChain; p; p = p->next) {
|
||||||
if (p->prefix == fname[0])
|
if (p->prefix == fname[0])
|
||||||
return testopen(p, f, fname+2);
|
return testopen(p, f, fname+2) ? f : 0;
|
||||||
}
|
}
|
||||||
// File not found
|
// File not found
|
||||||
break;
|
break;
|
||||||
|
@ -288,7 +329,7 @@ GFILE *gfileOpen(const char *fname, const char *mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// No available slot
|
// No available slot
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -300,7 +341,7 @@ GFILE *gfileOpen(const char *fname, const char *mode) {
|
||||||
f->flags = flags;
|
f->flags = flags;
|
||||||
for(p = FsChain; p; p = p->next) {
|
for(p = FsChain; p; p = p->next) {
|
||||||
if (testopen(p, f, fname))
|
if (testopen(p, f, fname))
|
||||||
return TRUE;
|
return f;
|
||||||
}
|
}
|
||||||
// File not found
|
// File not found
|
||||||
break;
|
break;
|
||||||
|
@ -308,7 +349,7 @@ GFILE *gfileOpen(const char *fname, const char *mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// No available slot
|
// No available slot
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS
|
#if GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS
|
||||||
|
@ -320,24 +361,23 @@ GFILE *gfileOpen(const char *fname, const char *mode) {
|
||||||
if (!(f->flags & GFILEFLG_OPEN)) {
|
if (!(f->flags & GFILEFLG_OPEN)) {
|
||||||
// Get the flags
|
// Get the flags
|
||||||
if (!(f->flags = mode2flags(mode)))
|
if (!(f->flags = mode2flags(mode)))
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
// If we want write but the fs doesn't allow it then return
|
// If we want write but the fs doesn't allow it then return
|
||||||
if ((f->flags & GFILEFLG_WRITE) && !(FsCHIBIOSVMT.flags & GFSFLG_WRITEABLE))
|
if ((f->flags & GFILEFLG_WRITE) && !(FsCHIBIOSVMT.flags & GFSFLG_WRITEABLE))
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
// File is open - fill in all the details
|
// File is open - fill in all the details
|
||||||
f->vmt = &FsCHIBIOSVMT;
|
f->vmt = &FsCHIBIOSVMT;
|
||||||
f->fd = BaseFileStreamPtr;
|
f->obj = BaseFileStreamPtr;
|
||||||
f->err = 0;
|
|
||||||
f->pos = 0;
|
f->pos = 0;
|
||||||
f->flags |= GFILEFLG_OPEN|GFILEFLG_CANSEEK;
|
f->flags |= GFILEFLG_OPEN|GFILEFLG_CANSEEK;
|
||||||
return TRUE;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No available slot
|
// No available slot
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -350,24 +390,23 @@ GFILE *gfileOpen(const char *fname, const char *mode) {
|
||||||
if (!(f->flags & GFILEFLG_OPEN)) {
|
if (!(f->flags & GFILEFLG_OPEN)) {
|
||||||
// Get the flags
|
// Get the flags
|
||||||
if (!(f->flags = mode2flags(mode)))
|
if (!(f->flags = mode2flags(mode)))
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
// If we want write but the fs doesn't allow it then return
|
// If we want write but the fs doesn't allow it then return
|
||||||
if ((f->flags & GFILEFLG_WRITE) && !(FsMemVMT.flags & GFSFLG_WRITEABLE))
|
if ((f->flags & GFILEFLG_WRITE) && !(FsMemVMT.flags & GFSFLG_WRITEABLE))
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
// File is open - fill in all the details
|
// File is open - fill in all the details
|
||||||
f->vmt = &FsMemVMT;
|
f->vmt = &FsMemVMT;
|
||||||
f->fd = memptr;
|
f->obj = memptr;
|
||||||
f->err = 0;
|
|
||||||
f->pos = 0;
|
f->pos = 0;
|
||||||
f->flags |= GFILEFLG_OPEN|GFILEFLG_CANSEEK;
|
f->flags |= GFILEFLG_OPEN|GFILEFLG_CANSEEK;
|
||||||
return TRUE;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No available slot
|
// No available slot
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -379,7 +418,7 @@ void gfileClose(GFILE *f) {
|
||||||
f->flags = 0;
|
f->flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t gfileRead(GFILE *f, char *buf, size_t len) {
|
size_t gfileRead(GFILE *f, void *buf, size_t len) {
|
||||||
size_t res;
|
size_t res;
|
||||||
|
|
||||||
if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_READ)) != (GFILEFLG_OPEN|GFILEFLG_READ))
|
if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_READ)) != (GFILEFLG_OPEN|GFILEFLG_READ))
|
||||||
|
@ -392,7 +431,7 @@ size_t gfileRead(GFILE *f, char *buf, size_t len) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t gfileWrite(GFILE *f, const char *buf, size_t len) {
|
size_t gfileWrite(GFILE *f, const void *buf, size_t len) {
|
||||||
size_t res;
|
size_t res;
|
||||||
|
|
||||||
if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_WRITE)) != (GFILEFLG_OPEN|GFILEFLG_WRITE))
|
if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_WRITE)) != (GFILEFLG_OPEN|GFILEFLG_WRITE))
|
||||||
|
@ -417,6 +456,7 @@ bool_t gfileSetPos(GFILE *f, long int pos) {
|
||||||
if (!f->vmt->setpos || !f->vmt->setpos(f, pos))
|
if (!f->vmt->setpos || !f->vmt->setpos(f, pos))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
f->pos = pos;
|
f->pos = pos;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
long int gfileGetSize(GFILE *f) {
|
long int gfileGetSize(GFILE *f) {
|
||||||
|
@ -442,16 +482,16 @@ bool_t gfileEOF(GFILE *f) {
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// Special String VMT
|
// Special String VMT
|
||||||
static int StringRead(GFILE *f, char *buf, int size) {
|
static int StringRead(GFILE *f, void *buf, int size) {
|
||||||
// size must be 1 for a complete read
|
// size must be 1 for a complete read
|
||||||
if (!((char *)f->obj)[f->pos])
|
if (!((char *)f->obj)[f->pos])
|
||||||
return 0;
|
return 0;
|
||||||
buf[0] = ((char *)f->obj)[f->pos];
|
((char *)buf)[0] = ((char *)f->obj)[f->pos];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
static int StringWrite(GFILE *f, const char *buf, int size) {
|
static int StringWrite(GFILE *f, const void *buf, int size) {
|
||||||
// size must be 1 for a complete write
|
// size must be 1 for a complete write
|
||||||
((char *)f->obj)[f->pos] = buf[0];
|
((char *)f->obj)[f->pos] = ((char *)buf)[0];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
static const GFILEVMT StringVMT = {
|
static const GFILEVMT StringVMT = {
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
********************************************************/
|
********************************************************/
|
||||||
|
|
||||||
static void ChibiOSBFSClose(GFILE *f);
|
static void ChibiOSBFSClose(GFILE *f);
|
||||||
static int ChibiOSBFSRead(GFILE *f, char *buf, int size);
|
static int ChibiOSBFSRead(GFILE *f, void *buf, int size);
|
||||||
static int ChibiOSBFSWrite(GFILE *f, char *buf, int size);
|
static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size);
|
||||||
static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos);
|
static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos);
|
||||||
static long int ChibiOSBFSGetsize(GFILE *f);
|
static long int ChibiOSBFSGetsize(GFILE *f);
|
||||||
static bool_t ChibiOSBFSEof(GFILE *f);
|
static bool_t ChibiOSBFSEof(GFILE *f);
|
||||||
|
@ -32,10 +32,10 @@ static const GFILEVMT FsCHIBIOSVMT = {
|
||||||
static void ChibiOSBFSClose(GFILE *f) {
|
static void ChibiOSBFSClose(GFILE *f) {
|
||||||
chFileStreamClose(((BaseFileStream *)f->fd));
|
chFileStreamClose(((BaseFileStream *)f->fd));
|
||||||
}
|
}
|
||||||
static int ChibiOSBFSRead(GFILE *f, char *buf, int size) {
|
static int ChibiOSBFSRead(GFILE *f, void *buf, int size) {
|
||||||
return chSequentialStreamRead(((BaseFileStream *)f->fd), (uint8_t *)buf, size);
|
return chSequentialStreamRead(((BaseFileStream *)f->fd), (uint8_t *)buf, size);
|
||||||
}
|
}
|
||||||
static int ChibiOSBFSWrite(GFILE *f, char *buf, int size) {
|
static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size) {
|
||||||
return chSequentialStreamWrite(((BaseFileStream *)f->fd), (uint8_t *)buf, size);
|
return chSequentialStreamWrite(((BaseFileStream *)f->fd), (uint8_t *)buf, size);
|
||||||
}
|
}
|
||||||
static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos) {
|
static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos) {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static int MEMRead(GFILE *f, char *buf, int size);
|
static int MEMRead(GFILE *f, void *buf, int size);
|
||||||
static int MEMWrite(GFILE *f, char *buf, int size);
|
static int MEMWrite(GFILE *f, const void *buf, int size);
|
||||||
static bool_t MEMSetpos(GFILE *f, long int pos);
|
static bool_t MEMSetpos(GFILE *f, long int pos);
|
||||||
|
|
||||||
static const GFILEVMT FsMemVMT = {
|
static const GFILEVMT FsMemVMT = {
|
||||||
|
@ -28,14 +28,16 @@ static const GFILEVMT FsMemVMT = {
|
||||||
MEMSetpos, 0, 0,
|
MEMSetpos, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int MEMRead(GFILE *f, char *buf, int size) {
|
static int MEMRead(GFILE *f, void *buf, int size) {
|
||||||
memset(buf, ((char *)f->fd)+f->pos, size);
|
memcpy(buf, ((char *)f->obj)+f->pos, size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
static int MEMWrite(GFILE *f, char *buf, int size) {
|
static int MEMWrite(GFILE *f, const void *buf, int size) {
|
||||||
memset(((char *)f->fd)+f->pos, buf, size);
|
memcpy(((char *)f->obj)+f->pos, buf, size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
static bool_t MEMSetpos(GFILE *f, long int pos) {
|
static bool_t MEMSetpos(GFILE *f, long int pos) {
|
||||||
|
(void) f;
|
||||||
|
(void) pos;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ static long int NativeFilesize(const char *fname);
|
||||||
static bool_t NativeRen(const char *oldname, const char *newname);
|
static bool_t NativeRen(const char *oldname, const char *newname);
|
||||||
static bool_t NativeOpen(GFILE *f, const char *fname);
|
static bool_t NativeOpen(GFILE *f, const char *fname);
|
||||||
static void NativeClose(GFILE *f);
|
static void NativeClose(GFILE *f);
|
||||||
static int NativeRead(GFILE *f, char *buf, int size);
|
static int NativeRead(GFILE *f, void *buf, int size);
|
||||||
static int NativeWrite(GFILE *f, const char *buf, int size);
|
static int NativeWrite(GFILE *f, const void *buf, int size);
|
||||||
static bool_t NativeSetpos(GFILE *f, long int pos);
|
static bool_t NativeSetpos(GFILE *f, long int pos);
|
||||||
static long int NativeGetsize(GFILE *f);
|
static long int NativeGetsize(GFILE *f);
|
||||||
static bool_t NativeEof(GFILE *f);
|
static bool_t NativeEof(GFILE *f);
|
||||||
|
@ -85,8 +85,8 @@ static bool_t NativeOpen(GFILE *f, const char *fname) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
static void NativeClose(GFILE *f) { fclose((FILE *)f->obj); }
|
static void NativeClose(GFILE *f) { fclose((FILE *)f->obj); }
|
||||||
static int NativeRead(GFILE *f, char *buf, int size) { return fread(buf, 1, size, (FILE *)f->obj); }
|
static int NativeRead(GFILE *f, void *buf, int size) { return fread(buf, 1, size, (FILE *)f->obj); }
|
||||||
static int NativeWrite(GFILE *f, const char *buf, int size) { return fwrite(buf, 1, size, (FILE *)f->obj); }
|
static int NativeWrite(GFILE *f, const void *buf, int size) { return fwrite(buf, 1, size, (FILE *)f->obj); }
|
||||||
static bool_t NativeSetpos(GFILE *f, long int pos) {
|
static bool_t NativeSetpos(GFILE *f, long int pos) {
|
||||||
return fseek((FILE *)f->obj, pos, SEEK_SET) ? FALSE : TRUE;
|
return fseek((FILE *)f->obj, pos, SEEK_SET) ? FALSE : TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ static bool_t ROMExists(const char *fname);
|
||||||
static long int ROMFilesize(const char *fname);
|
static long int ROMFilesize(const char *fname);
|
||||||
static bool_t ROMOpen(GFILE *f, const char *fname);
|
static bool_t ROMOpen(GFILE *f, const char *fname);
|
||||||
static void ROMClose(GFILE *f);
|
static void ROMClose(GFILE *f);
|
||||||
static int ROMRead(GFILE *f, char *buf, int size);
|
static int ROMRead(GFILE *f, void *buf, int size);
|
||||||
static bool_t ROMSetpos(GFILE *f, long int pos);
|
static bool_t ROMSetpos(GFILE *f, long int pos);
|
||||||
static long int ROMGetsize(GFILE *f);
|
static long int ROMGetsize(GFILE *f);
|
||||||
static bool_t ROMEof(GFILE *f);
|
static bool_t ROMEof(GFILE *f);
|
||||||
|
@ -72,7 +72,7 @@ static bool_t ROMOpen(GFILE *f, const char *fname) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
static void ROMClose(GFILE *f) { (void)f; }
|
static void ROMClose(GFILE *f) { (void)f; }
|
||||||
static int ROMRead(GFILE *f, char *buf, int size) {
|
static int ROMRead(GFILE *f, void *buf, int size) {
|
||||||
const ROMFS_DIRENTRY *p;
|
const ROMFS_DIRENTRY *p;
|
||||||
|
|
||||||
p = (const ROMFS_DIRENTRY *)f->obj;
|
p = (const ROMFS_DIRENTRY *)f->obj;
|
||||||
|
|
Loading…
Add table
Reference in a new issue