storage_message.h 2.5 KB

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