Jo Engine  2023.08.26
Jo Sega Saturn Engine
Data Structures | Macros | Enumerations | Functions
backup.h File Reference

Jo Engine saving features function prototypes. More...

Go to the source code of this file.

Data Structures

struct  jo_backup
 Backup File struct. More...
 

Macros

#define JO_BACKUP_MAX_FILENAME_LENGTH
 Max backup filename length. More...
 
#define JO_BACKUP_MAX_FILE
 Max backup file in device. More...
 
#define JO_BACKUP_MAX_COMMENT_LENGTH
 Max backup file comment length. More...
 

Enumerations

enum  jo_backup_device { JoInternalMemoryBackup, JoCartridgeMemoryBackup, JoExternalDeviceBackup }
 Backup device type. More...
 
enum  jo_backup_status {
  JoBackupStatusOk, JoBackupStatusWriteProtect, JoBackupStatusOutOfMemory, JoBackupStatusNotFound,
  JoBackupStatusNoMatch, JoBackupStatusBroken, JoBackupStatusUnknown
}
 Backup status. More...
 

Functions

bool jo_backup_mount (const jo_backup_device backup_device)
 Mount the backup device (must be the first call) More...
 
bool jo_backup_unmount (const jo_backup_device backup_device)
 Unmount the backup device (optional) More...
 
bool jo_backup_read_device (const jo_backup_device backup_device, jo_list *const filenames)
 Read backup device. More...
 
bool jo_backup_file_exists (const jo_backup_device backup_device, const char *const fname)
 Check if file exists. More...
 
bool jo_backup_format_device (const jo_backup_device backup_device)
 Format the device (all data is lost) More...
 
void jo_backup_init_file (jo_backup *file)
 Initialize a backup file in order to save it. More...
 
bool jo_backup_save (jo_backup *file)
 Save file contents to the backup device (if the file exists it will be overwritten) More...
 
static __jo_force_inline bool jo_backup_save_file_contents (const jo_backup_device backup_device, char *const fname, char *const comment, void *contents, unsigned int content_size)
 Save file contents to the backup device (if the file exists it will be overwritten) More...
 
bool jo_backup_delete_file (const jo_backup_device backup_device, const char *const fname)
 Delete file on the backup device. More...
 
bool jo_backup_get_file_last_modified_date (const jo_backup_device backup_device, const char *const fname, jo_datetime *datetime)
 Get file last modified date on the backup device. More...
 
bool jo_backup_get_file_size (const jo_backup_device backup_device, const char *const fname, unsigned int *const num_bytes, unsigned int *const num_blocks)
 Get file size in bytes and blocks. More...
 
bool jo_backup_get_file_info (const jo_backup_device backup_device, const char *const fname, char *const comment, unsigned char *const language_num, unsigned int *const date, unsigned int *const num_bytes, unsigned int *const num_blocks)
 Get file comment, language, date, and size in bytes and blocks. More...
 
unsigned char * jo_backup_load_file_comment (const jo_backup_device backup_device, const char *const fname)
 Load file comment from the backup device. More...
 
void * jo_backup_load_file_contents (const jo_backup_device backup_device, const char *const fname, unsigned int *length)
 Load file contents from the backup device. More...
 
unsigned short jo_backup_get_file_partition (const jo_backup_device backup_device, const char *const fname)
 Get the partition number where the file is located. More...
 
int jo_backup_get_free_block_count (const jo_backup_device backup_device)
 Get free block count on the backup device. More...
 
int jo_backup_get_total_block_count (const jo_backup_device backup_device)
 Get total block count on the backup device. More...
 
jo_backup_status jo_backup_get_last_status (const jo_backup_device backup_device)
 Get last backup status (error details) More...
 

Detailed Description

Jo Engine saving features function prototypes.

Author
Johannes Fetz
Todo:
List directory
Bug:
No known bugs.

Data Structure Documentation

◆ jo_backup

struct jo_backup

Backup File struct.

Data Fields
jo_backup_device backup_device
char * comment
unsigned int content_size
void * contents
char * fname
jo_language language
unsigned char language_num
unsigned short partition_number
jo_datetime save_datetime
unsigned int save_timestamp

Macro Definition Documentation

◆ JO_BACKUP_MAX_COMMENT_LENGTH

#define JO_BACKUP_MAX_COMMENT_LENGTH

Max backup file comment length.

◆ JO_BACKUP_MAX_FILE

#define JO_BACKUP_MAX_FILE

Max backup file in device.

◆ JO_BACKUP_MAX_FILENAME_LENGTH

#define JO_BACKUP_MAX_FILENAME_LENGTH

Max backup filename length.

Enumeration Type Documentation

◆ jo_backup_device

Backup device type.

Warning
If you change these values, the program will crash
Enumerator
JoInternalMemoryBackup 
JoCartridgeMemoryBackup 
JoExternalDeviceBackup 

◆ jo_backup_status

Backup status.

Enumerator
JoBackupStatusOk 
JoBackupStatusWriteProtect 
JoBackupStatusOutOfMemory 
JoBackupStatusNotFound 
JoBackupStatusNoMatch 
JoBackupStatusBroken 
JoBackupStatusUnknown 

Function Documentation

◆ jo_backup_delete_file()

bool jo_backup_delete_file ( const jo_backup_device  backup_device,
const char *const  fname 
)

Delete file on the backup device.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
Returns
true if succeed

◆ jo_backup_file_exists()

bool jo_backup_file_exists ( const jo_backup_device  backup_device,
const char *const  fname 
)

Check if file exists.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
Returns
true if the file exists

◆ jo_backup_format_device()

bool jo_backup_format_device ( const jo_backup_device  backup_device)

Format the device (all data is lost)

Parameters
backup_deviceBackup device
Returns
true if succeed

◆ jo_backup_get_file_info()

bool jo_backup_get_file_info ( const jo_backup_device  backup_device,
const char *const  fname,
char *const  comment,
unsigned char *const  language_num,
unsigned int *const  date,
unsigned int *const  num_bytes,
unsigned int *const  num_blocks 
)

Get file comment, language, date, and size in bytes and blocks.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
commentOutput comment (min 11 characters space)
language_numOutput language in native format
dateOutput date in native format
num_bytesOutput file size in bytes
num_blocksOutput file size in blocks
Returns
true if succeed

◆ jo_backup_get_file_last_modified_date()

bool jo_backup_get_file_last_modified_date ( const jo_backup_device  backup_device,
const char *const  fname,
jo_datetime datetime 
)

Get file last modified date on the backup device.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
datetimeOutput date and time (not NULL)
Returns
true if succeed

◆ jo_backup_get_file_partition()

unsigned short jo_backup_get_file_partition ( const jo_backup_device  backup_device,
const char *const  fname 
)

Get the partition number where the file is located.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
Returns
Partition number where the file is located

◆ jo_backup_get_file_size()

bool jo_backup_get_file_size ( const jo_backup_device  backup_device,
const char *const  fname,
unsigned int *const  num_bytes,
unsigned int *const  num_blocks 
)

Get file size in bytes and blocks.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
num_bytesOutput file size in bytes
num_blocksOutput file size in blocks
Returns
true if succeed

◆ jo_backup_get_free_block_count()

int jo_backup_get_free_block_count ( const jo_backup_device  backup_device)

Get free block count on the backup device.

Parameters
backup_deviceBackup device
Returns
Free block count

◆ jo_backup_get_last_status()

jo_backup_status jo_backup_get_last_status ( const jo_backup_device  backup_device)

Get last backup status (error details)

Parameters
backup_deviceBackup device
Returns
Backup status

◆ jo_backup_get_total_block_count()

int jo_backup_get_total_block_count ( const jo_backup_device  backup_device)

Get total block count on the backup device.

Parameters
backup_deviceBackup device
Returns
Free block count

◆ jo_backup_init_file()

void jo_backup_init_file ( jo_backup file)

Initialize a backup file in order to save it.

Parameters
fileBackup file to initialize

◆ jo_backup_load_file_comment()

unsigned char* jo_backup_load_file_comment ( const jo_backup_device  backup_device,
const char *const  fname 
)

Load file comment from the backup device.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
Returns
Comment (max 10 characters)

◆ jo_backup_load_file_contents()

void* jo_backup_load_file_contents ( const jo_backup_device  backup_device,
const char *const  fname,
unsigned int *  length 
)

Load file contents from the backup device.

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
lengthFile length (optional, pass JO_NULL to ignore)
Returns
File contents

◆ jo_backup_mount()

bool jo_backup_mount ( const jo_backup_device  backup_device)

Mount the backup device (must be the first call)

Parameters
backup_deviceBackup device
Returns
true if succeed

◆ jo_backup_read_device()

bool jo_backup_read_device ( const jo_backup_device  backup_device,
jo_list *const  filenames 
)

Read backup device.

Parameters
backup_deviceBackup device
filenamesOutput filenames. the list must be initialized (jo_list_init)
Returns
true if succeed

◆ jo_backup_save()

bool jo_backup_save ( jo_backup file)

Save file contents to the backup device (if the file exists it will be overwritten)

Parameters
fileBackup file to save
Returns
true if succeed

◆ jo_backup_save_file_contents()

static __jo_force_inline bool jo_backup_save_file_contents ( const jo_backup_device  backup_device,
char *const  fname,
char *const  comment,
void *  contents,
unsigned int  content_size 
)
static

Save file contents to the backup device (if the file exists it will be overwritten)

Parameters
backup_deviceBackup device
fnameFile name (max 11 characters not NULL)
commentComment (max 10 characters not NULL)
contentsData (not NULL or empty)
content_sizeData size
Returns
true if succeed

◆ jo_backup_unmount()

bool jo_backup_unmount ( const jo_backup_device  backup_device)

Unmount the backup device (optional)

Parameters
backup_deviceBackup device
Returns
true if succeed