api_fs.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef _API_FS_H
  2. #define _API_FS_H
  3. #define SEEK_SET 0
  4. #define SEEK_CUR 1
  5. #define SCAN_SUB_FOLDER 0x01 //是否需要扫描子目录
  6. #define SCAN_SPEED 0x10 //使用搜文件加速
  7. /* Results of Disk Functions */
  8. typedef enum {
  9. RES_OK = 0, /* 0: Function succeeded */
  10. RES_ERROR, /* 1: Disk error */
  11. RES_NOTRDY, /* 2: Not ready */
  12. RES_PARERR /* 3: Invalid parameter */
  13. } DRESULT;
  14. /* File function return code (FRESULT) */
  15. typedef enum {
  16. FR_OK = 0, /* 0 */
  17. FR_DISK_ERR, /* 1 */
  18. FR_INT_ERR, /* 2 */
  19. FR_NOT_READY, /* 3 */
  20. FR_NO_FILE, /* 4 */
  21. FR_NOT_OPENED, /* 5 */
  22. FR_NOT_ENABLED, /* 6 */
  23. FR_NO_FILESYSTEM, /* 7 */
  24. FR_EXIST, /* 8 */
  25. FR_DENIED, /* 9 */
  26. FR_INVALID_NAME, /* 10 */
  27. FR_NOT_ENOUGH_CORE, /* 11 */
  28. } FRESULT;
  29. /* File access mode and open method flags (2rd argument of f_open) */
  30. #define FA_READ 0x01
  31. #define FA_WRITE 0x02
  32. #define FA_CREATE_NEW 0x04
  33. #define FA_CREATE_ALWAYS 0x08
  34. /* FAT sub type (FATFS.fs_type) */
  35. #define FS_FAT12 1
  36. #define FS_FAT16 2
  37. #define FS_FAT32 3
  38. #define FS_EXFAT 4
  39. FRESULT fs_read (void* buff, UINT btr, UINT* br); /* Read data from the open file */
  40. FRESULT fs_lseek (DWORD ofs, u8 whence); /* Move file pointer of the open file */
  41. FRESULT fs_write (void* buff, UINT btw); /* Write data to the open file */
  42. DRESULT disk_readp (BYTE* buff, DWORD sector); /* Read Partial Sector */
  43. DRESULT disk_writep (BYTE* buff, DWORD sector); /* Write Partial Sector */
  44. FRESULT fs_read_lrc(void* buff, UINT btr, UINT* br); /* Read data from the lrc open file */
  45. FRESULT fs_lseek_lrc(DWORD ofs, u8 whence); /* Move file pointer of the lrc open file */
  46. bool fs_mount(void);
  47. void fs_var_init(void);
  48. void fsdisk_callback_init(u8 dev_num);
  49. u16 fs_get_total_files(void); //扫描全盘文件,返回文件总数
  50. u16 fs_getdir_files(void); //扫描当前文件所在目录的文件总数
  51. u16 fs_get_dir_fstart(void); //获取当前文件夹起始文件编号
  52. u16 fs_get_dirs_count(void); //获取目录计数
  53. bool fs_open_num(u16 file_number); //根据文件编号打开文件
  54. u16 fs_open_dir_num(u16 dir_num); //根据文件夹编号打开目标文件夹,返回文件夹起始文件编号
  55. void fs_get_short_fname(char *fnbuf, u8 uppercase); //获取短文件名, uppercase = 0, 小写字母返回; uppercase = 1, 大写字母返回
  56. void fs_get_filename(char *fnbuf, u16 buf_len); //获取长文件名
  57. void fs_get_fname_extension(char *ext); //获取文件名后缀
  58. uint fs_get_dir_depth(void); //获取目录深度
  59. u32 fs_get_file_ssect(void); //获取文件起始sector
  60. u32 fs_get_file_size(void); //获取文件SIZE
  61. u8 fs_get_type(void); //获取文件系统类型
  62. u32 fs_get_file_count(void); //获取当前文件的编号
  63. u32 fs_get_ftime(void); //获取文件创建时间
  64. bool fs_get_filename_for_number(u16 file_number, u8 lfn, char *fnbuf, u16 buf_len); //根据文件编号获取文件名字
  65. FRESULT fs_mkdir(const char *path); //创建短文件名目录
  66. FRESULT fs_mkdir_lfn(const char *path, const char *lfn); //创建长文件名目录
  67. FRESULT fs_open(const char *path, u8 mode); //按路径打开或创建文件(短文件名创建文件)
  68. FRESULT fs_open_lfn(const char *path, const char *lfn, u8 mode); //按路径打开或创建文件(长文件名创建文件)
  69. FRESULT fs_close(void); //Close File
  70. FRESULT fs_sync(void); //Synchronize the File
  71. FRESULT fs_open_lrc(char *lfn); //打开当前歌曲的歌词文件
  72. bool fs_delete(u16 file_number); //删除指定number文件
  73. void rec_mp3_filelen_reduce(u16 ms);
  74. void fs_scan_set(u8 mode, u8 (*file_filter)(void), u8 (*dir_filter)(void));
  75. ///点阵屏文件导航相关的API函数
  76. u16 fs_nav_init(u16 file_num);
  77. void fs_nav_exit(void);
  78. u16 fs_nav_get_dirtotal(void);
  79. u16 fs_nav_dir_scan(void);
  80. u16 fs_nav_cd_updir(void);
  81. bool fs_nav_cd_subdir(u16 index);
  82. u16 fs_nav_get_file_number(u16 index);
  83. bool fs_nav_delete(u16 index);
  84. void fs_nav_cache_fill(void *buf, u16 start, u16 num);
  85. #endif // _API_FS_H