maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
RetroFile API

Abstraction layer for dealing with files on retro systems. More...

Collaboration diagram for RetroFile API:

Topics

 RetroFile Types
 Types of files/data stores that mfile can abstract from.
 

Files

file  mfile.h
 

Data Structures

union  MFILE_HANDLE
 
struct  MFILE_CADDY
 

Macros

#define MAUG_PATH_MAX   256
 Maximum size allocated for asset paths.
 
#define MFILE_FLAG_READ_ONLY   0x01
 
#define MFILE_READ_FLAG_LSBF   0x01
 
#define MFILE_TRACE_LVL   0
 
#define mfile_check_lock(p_file)
 
#define mfile_default_case(p_file)
 
#define mfile_has_bytes(p_file)
 
#define mfile_get_sz(p_file)
 

Typedefs

typedef MERROR_RETVAL(* mfile_seek_t) (struct MFILE_CADDY *p_file, off_t pos)
 
typedef MERROR_RETVAL(* mfile_read_int_t) (struct MFILE_CADDY *p_file, uint8_t *buf, size_t buf_sz, uint8_t flags)
 
typedef MERROR_RETVAL(* mfile_read_line_t) (struct MFILE_CADDY *p_file, char *buf, off_t buf_sz, uint8_t flags)
 
typedef struct MFILE_CADDY mfile_t
 

Functions

MERROR_RETVAL mfile_lock_buffer (MAUG_MHANDLE, off_t, mfile_t *p_file)
 Lock a buffer and assign it to an mfile_t to read/write.
 
MERROR_RETVAL mfile_open_read (const char *filename, mfile_t *p_file)
 Open a file and read it into memory or memory-map it.
 
void mfile_close (mfile_t *p_file)
 Close a file opened with mfile_open_read().
 

Detailed Description

Abstraction layer for dealing with files on retro systems.

Macro Definition Documentation

◆ mfile_check_lock

#define mfile_check_lock ( p_file)
Value:
(NULL != (p_file)->mem_buffer)

◆ mfile_default_case

#define mfile_default_case ( p_file)
Value:
default: \
error_printf( "unknown file type: %d", (p_file)->type ); \
break;

◆ mfile_get_sz

#define mfile_get_sz ( p_file)
Value:
((p_file)->sz)

◆ mfile_has_bytes

#define mfile_has_bytes ( p_file)
Value:
((MFILE_CADDY_TYPE_FILE == ((p_file)->type) ? \
(off_t)ftell( (p_file)->h.file ) : \
(p_file)->mem_cursor) < (p_file)->sz)
#define MFILE_CADDY_TYPE_FILE
A standard UNIX file.
Definition mfile.h:40

Function Documentation

◆ mfile_open_read()

MERROR_RETVAL mfile_open_read ( const char * filename,
mfile_t * p_file )

Open a file and read it into memory or memory-map it.

Parameters
filenameNULL-terminated path to file to open.