#ifndef _IO_H_
#define _IO_H_

#define MAX_ENTRY 1024
#define MAX_PATH 1024
#define MAX_NAME 256

#define ROMS_FOLDER "/ROMS/GB"
#define SRAM_FOLDER "/SAVEFILES/GB"

typedef struct {
        char         name[MAX_NAME];
		char         path[MAX_PATH];
        unsigned int size;
        unsigned int attr;
} BROWSERFILEINFO;

extern BROWSERFILEINFO *sortfiles[MAX_ENTRY];
extern int nfiles;

// GB supported extensions
enum {
	EXT_GB = 1,
	EXT_GZ = 2,
	EXT_ZIP = 4,
	EXT_TCH = 8,
	EXT_UNKNOWN = 16,
};

void io_init();
int io_file_read(char *filename, unsigned char *buffer, int size);
int io_file_write(char *filename, unsigned char *buffer, int size);

unsigned long io_get_extension(const char *szFilePath);
int io_load_folder_files(const char *path, unsigned long ext);

int io_save_sram(unsigned char *buf,int size);
int io_load_sram(unsigned char *buf, int bufsize);

#endif
