storage_message.h 2.8 KB

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