filesystem_api_defines.h 1.8 KB

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