filesystem-api-defines.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <furi.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /** Access mode flags */
  7. typedef enum {
  8. FSAM_READ = (1 << 0), /**< Read access */
  9. FSAM_WRITE = (1 << 1), /**< Write access */
  10. } FS_AccessMode;
  11. /** Open mode flags */
  12. typedef enum {
  13. FSOM_OPEN_EXISTING = 1, /**< Open file, fail if file doesn't exist */
  14. FSOM_OPEN_ALWAYS = 2, /**< Open file. Create new file if not exist */
  15. FSOM_OPEN_APPEND = 4, /**< Open file. Create new file if not exist. Set R/W pointer to EOF */
  16. FSOM_CREATE_NEW = 8, /**< Creates a new file. Fails if the file is exist */
  17. FSOM_CREATE_ALWAYS = 16, /**< Creates a new file. If file exist, truncate to zero size */
  18. } FS_OpenMode;
  19. /** API errors enumeration */
  20. typedef enum {
  21. FSE_OK, /**< No error */
  22. FSE_NOT_READY, /**< FS not ready */
  23. FSE_EXIST, /**< File/Dir alrady exist */
  24. FSE_NOT_EXIST, /**< File/Dir does not exist */
  25. FSE_INVALID_PARAMETER, /**< Invalid API parameter */
  26. FSE_DENIED, /**< Access denied */
  27. FSE_INVALID_NAME, /**< Invalid name/path */
  28. FSE_INTERNAL, /**< Internal error */
  29. FSE_NOT_IMPLEMENTED, /**< Functon not implemented */
  30. FSE_ALREADY_OPEN, /**< File/Dir already opened */
  31. } FS_Error;
  32. /** FileInfo flags */
  33. typedef enum {
  34. FSF_DIRECTORY = (1 << 0), /**< Directory */
  35. } FS_Flags;
  36. /** Structure that hold file index and returned api errors */
  37. typedef struct File File;
  38. /** Structure that hold file info */
  39. typedef struct {
  40. uint8_t flags; /**< flags from FS_Flags enum */
  41. uint64_t size; /**< file size */
  42. } FileInfo;
  43. /** Gets the error text from FS_Error
  44. * @param error_id error id
  45. * @return const char* error text
  46. */
  47. const char* filesystem_api_error_get_desc(FS_Error error_id);
  48. #ifdef __cplusplus
  49. }
  50. #endif