dirent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <stddef.h>
  16. #include <stdint.h>
  17. /**
  18. * This header file provides POSIX-compatible definitions of directory
  19. * access functions and related data types.
  20. * See http://pubs.opengroup.org/onlinepubs/7908799/xsh/dirent.h.html
  21. * for reference.
  22. */
  23. /**
  24. * @brief Opaque directory structure
  25. */
  26. typedef struct {
  27. uint16_t dd_vfs_idx; /*!< VFS index, not to be used by applications */
  28. uint16_t dd_rsv; /*!< field reserved for future extension */
  29. /* remaining fields are defined by VFS implementation */
  30. } DIR;
  31. /**
  32. * @brief Directory entry structure
  33. */
  34. struct dirent {
  35. int d_ino; /*!< file number */
  36. uint8_t d_type; /*!< not defined in POSIX, but present in BSD and Linux */
  37. #define DT_UNKNOWN 0
  38. #define DT_REG 1
  39. #define DT_DIR 2
  40. char d_name[256]; /*!< zero-terminated file name */
  41. };
  42. DIR* opendir(const char* name);
  43. struct dirent* readdir(DIR* pdir);
  44. long telldir(DIR* pdir);
  45. void seekdir(DIR* pdir, long loc);
  46. void rewinddir(DIR* pdir);
  47. int closedir(DIR* pdir);
  48. int readdir_r(DIR* pdir, struct dirent* entry, struct dirent** out_dirent);