fat.h 764 B

123456789101112131415161718192021
  1. /* FAT12 read-only filesystem. Root directory only.
  2. * Error conventions: 0 = success, -1 = not found / not ready, -2 = disk I/O error. */
  3. #ifndef FAT_H
  4. #define FAT_H
  5. typedef void (*fat_root_callback_t)(const char *name, int is_dir, unsigned int size);
  6. /* Parse BPB from sector 0. Call once before list/read.
  7. * Returns 0 on success, -1 on error. */
  8. int fat_init(void);
  9. /* Iterate root directory, call callback for each file/dir.
  10. * Returns 0 on success, -1 if not ready, -2 on disk I/O error. */
  11. int fat_list_root(fat_root_callback_t callback);
  12. /* Read file by 8.3 name into buf, max max_len bytes.
  13. * Returns bytes read on success, -1 if not found, -2 on disk I/O error. */
  14. int fat_read_file(const char *name_8_3, void *buf, unsigned int max_len);
  15. #endif