fs_interface.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2016 Intel Corporation.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_
  7. #define ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_
  8. #include <stdint.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #if 0
  13. #if (CONFIG_FILE_SYSTEM_MAX_FILE_NAME - 0) > 0
  14. #define MAX_FILE_NAME CONFIG_FILE_SYSTEM_MAX_FILE_NAME
  15. #else /* CONFIG_FILE_SYSTEM_MAX_FILE_NAME */
  16. /* Select from enabled file systems */
  17. #if defined(CONFIG_FILE_SYSTEM_LITTLEFS)
  18. #define MAX_FILE_NAME 256
  19. #elif defined(CONFIG_FAT_FILESYSTEM_ELM)
  20. #if defined(CONFIG_FS_FATFS_LFN)
  21. #define MAX_FILE_NAME CONFIG_FS_FATFS_MAX_LFN
  22. #else /* CONFIG_FS_FATFS_LFN */
  23. #define MAX_FILE_NAME 12 /* Uses 8.3 SFN */
  24. #endif /* CONFIG_FS_FATFS_LFN */
  25. #else /* filesystem selection */
  26. /* Use standard 8.3 when no filesystem is explicitly selected */
  27. #define MAX_FILE_NAME 12
  28. #endif /* filesystem selection */
  29. #endif /* CONFIG_FILE_SYSTEM_MAX_FILE_NAME */
  30. #endif
  31. /* Type for fs_open flags */
  32. typedef uint8_t fs_mode_t;
  33. #if CONFIG_XSFN_OPT == 0
  34. #define MAX_FILE_NAME 256 /* max file name len */
  35. #define MAX_URL_LEN 512
  36. #else
  37. #if _USE_XSFN
  38. #define MAX_FILE_NAME 32
  39. #define MAX_URL_LEN 256
  40. //#define MAX_FILE_NAME 256 //max url ?
  41. #else
  42. #define MAX_FILE_NAME 12 /* Uses 8.3 SFN */
  43. #define MAX_URL_LEN 256
  44. #endif
  45. #endif
  46. struct fs_mount_t;
  47. /**
  48. * @addtogroup file_system_api
  49. * @{
  50. */
  51. /**
  52. * @brief File object representing an open file
  53. *
  54. * The object needs to be initialized with function fs_file_t_init().
  55. *
  56. * @param Pointer to FATFS file object structure
  57. * @param mp Pointer to mount point structure
  58. */
  59. struct fs_file_t {
  60. void *filep;
  61. const struct fs_mount_t *mp;
  62. fs_mode_t flags;
  63. };
  64. /**
  65. * @brief Directory object representing an open directory
  66. *
  67. * The object needs to be initialized with function fs_dir_t_init().
  68. *
  69. * @param dirp Pointer to directory object structure
  70. * @param mp Pointer to mount point structure
  71. */
  72. struct fs_dir_t {
  73. void *dirp;
  74. const struct fs_mount_t *mp;
  75. };
  76. /**
  77. * @}
  78. */
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /* ZEPHYR_INCLUDE_FS_FS_INTERFACE_H_ */