vfs.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef INCLUDE_VFS_H
  2. #define INCLUDE_VFS_H
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. #include "ff.h"
  8. #include "time.h"
  9. // #include <stddef.h>
  10. // #include <stdlib.h>
  11. #include <string.h>
  12. #define vfs_load_plugin(x)
  13. #define bcopy(src, dest, len) memmove(dest, src, len)
  14. typedef DIR vfs_dir_t;
  15. typedef FIL vfs_file_t;
  16. typedef struct
  17. {
  18. long st_size;
  19. char st_mode;
  20. time_t st_mtime;
  21. } vfs_stat_t;
  22. typedef struct
  23. {
  24. char name[13];
  25. } vfs_dirent_t;
  26. typedef FIL vfs_t;
  27. #define time(x)
  28. #define vfs_eof f_eof
  29. #define VFS_ISDIR(st_mode) ((st_mode)&AM_DIR)
  30. #define VFS_ISREG(st_mode) !((st_mode)&AM_DIR)
  31. #define vfs_rename(vfs, from, to) f_rename(from, to)
  32. #define VFS_IRWXU 0
  33. #define VFS_IRWXG 0
  34. #define VFS_IRWXO 0
  35. #define vfs_mkdir(vfs, name, mode) f_mkdir(name)
  36. #define vfs_rmdir(vfs, name) f_unlink(name)
  37. #define vfs_remove(vfs, name) f_unlink(name)
  38. #define vfs_chdir(vfs, dir) f_chdir(dir)
  39. char *vfs_getcwd(vfs_t *vfs, void *, int dummy);
  40. int vfs_read(void *buffer, int dummy, int len, vfs_file_t *file);
  41. int vfs_write(void *buffer, int dummy, int len, vfs_file_t *file);
  42. vfs_dirent_t *vfs_readdir(vfs_dir_t *dir);
  43. vfs_file_t *vfs_open(vfs_t *vfs, const char *filename, const char *mode);
  44. vfs_t *vfs_openfs();
  45. void vfs_close(vfs_t *vfs);
  46. int vfs_stat(vfs_t *vfs, const char *filename, vfs_stat_t *st);
  47. void vfs_closedir(vfs_dir_t *dir);
  48. vfs_dir_t *vfs_opendir(vfs_t *vfs, const char *path);
  49. // struct tm *gmtime(const time_t *c_t);
  50. #ifdef __cplusplus
  51. } /* extern "C" */
  52. #endif
  53. #endif /* INCLUDE_VFS_H */