Jo Engine  2020.06.22
Jo Sega Saturn Engine
Macros | Typedefs | Functions
fs.h File Reference

Jo Engine File System function prototypes. More...

Go to the source code of this file.

Macros

#define JO_ROOT_DIR
 Specify the root directory (on the CD) for jo_fs_read_file(), jo_map_load_from_file(), etc. More...
 
#define JO_CURRENT_DIR
 Specify the current directory (on the CD) for jo_fs_read_file(), jo_map_load_from_file(), etc. More...
 
#define JO_PARENT_DIR
 Specify the parent directory for jo_fs_read_file(), jo_map_load_from_file(), etc. More...
 

Typedefs

typedef void(* jo_fs_async_read_callback) (char *contents, int length, int optional_token)
 Function prototype for () More...
 

Functions

void jo_fs_cd (const char *const sub_dir)
 Change the current directory (equivalent of Unix cd command) More...
 
char * jo_fs_read_file_in_dir (const char *const filename, const char *const sub_dir, int *len)
 Read a file on the CD. More...
 
char * jo_fs_read_file_ptr (const char *const filename, void *buf, int *len)
 Read a file on the CD and put the contents to "buf". More...
 
static __jo_force_inline char * jo_fs_read_file (const char *const filename, int *len)
 Read a file on the CD. More...
 
bool jo_fs_read_file_async_ptr (const char *const filename, jo_fs_async_read_callback callback, int optional_token, void *buf)
 Read a file on the CD asynchronously and put the contents to "buf". More...
 
static __jo_force_inline bool jo_fs_read_file_async (const char *const filename, jo_fs_async_read_callback callback, int optional_token)
 Read a file on the CD asynchronously. More...
 
bool jo_fs_open (jo_file *const file, const char *const filename)
 Open a file. More...
 
void jo_fs_close (jo_file *const file)
 Close a file. More...
 
int jo_fs_read_next_bytes (jo_file *const file, char *buffer, unsigned int nbytes)
 Read bytes from a file. More...
 
bool jo_fs_seek_forward (jo_file *const file, unsigned int nbytes)
 Seek forward from current position of a file. More...
 

Detailed Description

Jo Engine File System function prototypes.

Author
Johannes Fetz
Bug:
No known bugs.

Macro Definition Documentation

◆ JO_CURRENT_DIR

#define JO_CURRENT_DIR

Specify the current directory (on the CD) for jo_fs_read_file(), jo_map_load_from_file(), etc.

◆ JO_PARENT_DIR

#define JO_PARENT_DIR

Specify the parent directory for jo_fs_read_file(), jo_map_load_from_file(), etc.

◆ JO_ROOT_DIR

#define JO_ROOT_DIR

Specify the root directory (on the CD) for jo_fs_read_file(), jo_map_load_from_file(), etc.

Typedef Documentation

◆ jo_fs_async_read_callback

typedef void(* jo_fs_async_read_callback) (char *contents, int length, int optional_token)

Function prototype for ()

Function Documentation

◆ jo_fs_cd()

void jo_fs_cd ( const char *const  sub_dir)

Change the current directory (equivalent of Unix cd command)

Parameters
sub_dirSub directory name (use JO_PARENT_DIR for parent directory)

◆ jo_fs_close()

void jo_fs_close ( jo_file *const  file)

Close a file.

Parameters
filePointer to an allocated and valid jo_file struct

◆ jo_fs_open()

bool jo_fs_open ( jo_file *const  file,
const char *const  filename 
)

Open a file.

Parameters
filePointer to an allocated jo_file struct
filenameFilename (upper case and shorter as possible like "A.TXT")
Returns
true if succeed

◆ jo_fs_read_file()

static __jo_force_inline char* jo_fs_read_file ( const char *const  filename,
int *  len 
)
static

Read a file on the CD.

Parameters
filenameFilename (upper case and shorter as possible like "A.TXT")
lenreturn the file length
Returns
The stream

◆ jo_fs_read_file_async()

static __jo_force_inline bool jo_fs_read_file_async ( const char *const  filename,
jo_fs_async_read_callback  callback,
int  optional_token 
)
static

Read a file on the CD asynchronously.

Parameters
filenameFilename (upper case and shorter as possible like "A.TXT")
callbackCallback called when the file is loaded
optional_tokenUser value to identify the file
Returns
true if succeed

◆ jo_fs_read_file_async_ptr()

bool jo_fs_read_file_async_ptr ( const char *const  filename,
jo_fs_async_read_callback  callback,
int  optional_token,
void *  buf 
)

Read a file on the CD asynchronously and put the contents to "buf".

Parameters
filenameFilename (upper case and shorter as possible like "A.TXT")
callbackCallback called when the file is loaded
optional_tokenUser value to identify the file
bufOutput buffer
Returns
true if succeed

◆ jo_fs_read_file_in_dir()

char* jo_fs_read_file_in_dir ( const char *const  filename,
const char *const  sub_dir,
int *  len 
)

Read a file on the CD.

Parameters
filenameFilename (upper case and shorter as possible like "A.TXT")
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
lenreturn the file length
Returns
The stream

◆ jo_fs_read_file_ptr()

char* jo_fs_read_file_ptr ( const char *const  filename,
void *  buf,
int *  len 
)

Read a file on the CD and put the contents to "buf".

Parameters
filenameFilename (upper case and shorter as possible like "A.TXT")
bufOutput buffer
lenreturn the file length
Returns
The stream

◆ jo_fs_read_next_bytes()

int jo_fs_read_next_bytes ( jo_file *const  file,
char *  buffer,
unsigned int  nbytes 
)

Read bytes from a file.

Parameters
filePointer to an allocated and valid jo_file struct
bufferPointer to an allocated buffer (length >= nbytes)
nbytesnumber of bytes to read
Returns
Number of bytes read (<= 0 means EOF)

◆ jo_fs_seek_forward()

bool jo_fs_seek_forward ( jo_file *const  file,
unsigned int  nbytes 
)

Seek forward from current position of a file.

Parameters
filePointer to an allocated and valid jo_file struct
nbytesnumber of bytes to skip
Returns
true if succeed