storage_message.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #pragma once
  2. #include <furi.h>
  3. #include <toolbox/api_lock.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct {
  8. File* file;
  9. const char* path;
  10. FS_AccessMode access_mode;
  11. FS_OpenMode open_mode;
  12. } SADataFOpen;
  13. typedef struct {
  14. File* file;
  15. void* buff;
  16. uint16_t bytes_to_read;
  17. } SADataFRead;
  18. typedef struct {
  19. File* file;
  20. const void* buff;
  21. uint16_t bytes_to_write;
  22. } SADataFWrite;
  23. typedef struct {
  24. File* file;
  25. uint32_t offset;
  26. bool from_start;
  27. } SADataFSeek;
  28. typedef struct {
  29. File* file;
  30. const char* path;
  31. } SADataDOpen;
  32. typedef struct {
  33. File* file;
  34. FileInfo* fileinfo;
  35. char* name;
  36. uint16_t name_length;
  37. } SADataDRead;
  38. typedef struct {
  39. const char* path;
  40. uint32_t* timestamp;
  41. } SADataCTimestamp;
  42. typedef struct {
  43. const char* path;
  44. FileInfo* fileinfo;
  45. } SADataCStat;
  46. typedef struct {
  47. const char* fs_path;
  48. uint64_t* total_space;
  49. uint64_t* free_space;
  50. } SADataCFSInfo;
  51. typedef struct {
  52. uint32_t id;
  53. } SADataError;
  54. typedef struct {
  55. const char* path;
  56. } SADataPath;
  57. typedef struct {
  58. File* file;
  59. } SADataFile;
  60. typedef struct {
  61. SDInfo* info;
  62. } SAInfo;
  63. typedef union {
  64. SADataFOpen fopen;
  65. SADataFRead fread;
  66. SADataFWrite fwrite;
  67. SADataFSeek fseek;
  68. SADataDOpen dopen;
  69. SADataDRead dread;
  70. SADataCTimestamp ctimestamp;
  71. SADataCStat cstat;
  72. SADataCFSInfo cfsinfo;
  73. SADataError error;
  74. SADataFile file;
  75. SADataPath path;
  76. SAInfo sdinfo;
  77. } SAData;
  78. typedef union {
  79. bool bool_value;
  80. uint16_t uint16_value;
  81. uint64_t uint64_value;
  82. FS_Error error_value;
  83. const char* cstring_value;
  84. } SAReturn;
  85. typedef enum {
  86. StorageCommandFileOpen,
  87. StorageCommandFileClose,
  88. StorageCommandFileRead,
  89. StorageCommandFileWrite,
  90. StorageCommandFileSeek,
  91. StorageCommandFileTell,
  92. StorageCommandFileTruncate,
  93. StorageCommandFileSize,
  94. StorageCommandFileSync,
  95. StorageCommandFileEof,
  96. StorageCommandDirOpen,
  97. StorageCommandDirClose,
  98. StorageCommandDirRead,
  99. StorageCommandDirRewind,
  100. StorageCommandCommonTimestamp,
  101. StorageCommandCommonStat,
  102. StorageCommandCommonRemove,
  103. StorageCommandCommonMkDir,
  104. StorageCommandCommonFSInfo,
  105. StorageCommandSDFormat,
  106. StorageCommandSDUnmount,
  107. StorageCommandSDInfo,
  108. StorageCommandSDStatus,
  109. } StorageCommand;
  110. typedef struct {
  111. FuriApiLock lock;
  112. StorageCommand command;
  113. SAData* data;
  114. SAReturn* return_data;
  115. } StorageMessage;
  116. #ifdef __cplusplus
  117. }
  118. #endif