romfile.h 942 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef _ROMFILE_H
  2. #define _ROMFILE_H
  3. #define ROMFILE_NAME_MAX_LEN 64
  4. typedef struct {
  5. char name[ROMFILE_NAME_MAX_LEN];
  6. unsigned int offset;
  7. unsigned int size;
  8. } RomFileInfo;
  9. typedef struct {
  10. unsigned int magic;
  11. unsigned int filenum;
  12. unsigned int romsize;
  13. unsigned int checksum;
  14. RomFileInfo files[];
  15. } RomHeader;
  16. typedef struct {
  17. char name[ROMFILE_NAME_MAX_LEN];
  18. void *buf;
  19. int cached_filenum;
  20. int life;
  21. } RomFileCache;
  22. typedef struct {
  23. void *buf;
  24. int index;
  25. int size;
  26. int pos;
  27. RomFileCache *cache;
  28. } RomFile;
  29. int ReadRomFile(void);
  30. RomFile *RomFileOpen(const char *name);
  31. size_t RomFileRead(RomFile *file, void *buf, size_t size);
  32. int RomFileSeek(RomFile *file, int offset, int whence);
  33. void RomFileClose(RomFile *file);
  34. const char * RomFileGetExt(const char * path);
  35. int RomFileTell(RomFile *file);
  36. int RomFileGetSize(RomFile *file);
  37. int RomFileExist(const char *name);
  38. int RomFileDirExist(const char *name);
  39. #endif