storage_message.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. FileInfo* fileinfo;
  40. } SADataCStat;
  41. typedef struct {
  42. const char* fs_path;
  43. uint64_t* total_space;
  44. uint64_t* free_space;
  45. } SADataCFSInfo;
  46. typedef struct {
  47. uint32_t id;
  48. } SADataError;
  49. typedef struct {
  50. const char* path;
  51. } SADataPath;
  52. typedef struct {
  53. File* file;
  54. } SADataFile;
  55. typedef struct {
  56. SDInfo* info;
  57. } SAInfo;
  58. typedef union {
  59. SADataFOpen fopen;
  60. SADataFRead fread;
  61. SADataFWrite fwrite;
  62. SADataFSeek fseek;
  63. SADataDOpen dopen;
  64. SADataDRead dread;
  65. SADataCStat cstat;
  66. SADataCFSInfo cfsinfo;
  67. SADataError error;
  68. SADataFile file;
  69. SADataPath path;
  70. SAInfo sdinfo;
  71. } SAData;
  72. typedef union {
  73. bool bool_value;
  74. uint16_t uint16_value;
  75. uint64_t uint64_value;
  76. FS_Error error_value;
  77. const char* cstring_value;
  78. } SAReturn;
  79. typedef enum {
  80. StorageCommandFileOpen,
  81. StorageCommandFileClose,
  82. StorageCommandFileRead,
  83. StorageCommandFileWrite,
  84. StorageCommandFileSeek,
  85. StorageCommandFileTell,
  86. StorageCommandFileTruncate,
  87. StorageCommandFileSize,
  88. StorageCommandFileSync,
  89. StorageCommandFileEof,
  90. StorageCommandDirOpen,
  91. StorageCommandDirClose,
  92. StorageCommandDirRead,
  93. StorageCommandDirRewind,
  94. StorageCommandCommonStat,
  95. StorageCommandCommonRemove,
  96. StorageCommandCommonMkDir,
  97. StorageCommandCommonFSInfo,
  98. StorageCommandSDFormat,
  99. StorageCommandSDUnmount,
  100. StorageCommandSDInfo,
  101. StorageCommandSDStatus,
  102. } StorageCommand;
  103. typedef struct {
  104. osSemaphoreId_t semaphore;
  105. StorageCommand command;
  106. SAData* data;
  107. SAReturn* return_data;
  108. } StorageMessage;
  109. #ifdef __cplusplus
  110. }
  111. #endif