Naze32 clone with Frysky receiver
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DirHandle.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2006-2013 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_DIRHANDLE_H
  17. #define MBED_DIRHANDLE_H
  18. #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
  19. # define NAME_MAX 255
  20. typedef int mode_t;
  21. #else
  22. # include <sys/syslimits.h>
  23. #endif
  24. #include "FileHandle.h"
  25. struct dirent {
  26. char d_name[NAME_MAX+1];
  27. };
  28. namespace mbed {
  29. /** Represents a directory stream. Objects of this type are returned
  30. * by a FileSystemLike's opendir method. Implementations must define
  31. * at least closedir, readdir and rewinddir.
  32. *
  33. * If a FileSystemLike class defines the opendir method, then the
  34. * directories of an object of that type can be accessed by
  35. * DIR *d = opendir("/example/directory") (or opendir("/example")
  36. * to open the root of the filesystem), and then using readdir(d) etc.
  37. *
  38. * The root directory is considered to contain all FileLike and
  39. * FileSystemLike objects, so the DIR* returned by opendir("/") will
  40. * reflect this.
  41. */
  42. class DirHandle {
  43. public:
  44. /** Closes the directory.
  45. *
  46. * @returns
  47. * 0 on success,
  48. * -1 on error.
  49. */
  50. virtual int closedir()=0;
  51. /** Return the directory entry at the current position, and
  52. * advances the position to the next entry.
  53. *
  54. * @returns
  55. * A pointer to a dirent structure representing the
  56. * directory entry at the current position, or NULL on reaching
  57. * end of directory or error.
  58. */
  59. virtual struct dirent *readdir()=0;
  60. /** Resets the position to the beginning of the directory.
  61. */
  62. virtual void rewinddir()=0;
  63. /** Returns the current position of the DirHandle.
  64. *
  65. * @returns
  66. * the current position,
  67. * -1 on error.
  68. */
  69. virtual off_t telldir() { return -1; }
  70. /** Sets the position of the DirHandle.
  71. *
  72. * @param location The location to seek to. Must be a value returned by telldir.
  73. */
  74. virtual void seekdir(off_t location) { }
  75. virtual ~DirHandle() {}
  76. };
  77. } // namespace mbed
  78. typedef mbed::DirHandle DIR;
  79. extern "C" {
  80. DIR *opendir(const char*);
  81. struct dirent *readdir(DIR *);
  82. int closedir(DIR*);
  83. void rewinddir(DIR*);
  84. long telldir(DIR*);
  85. void seekdir(DIR*, long);
  86. int mkdir(const char *name, mode_t n);
  87. };
  88. #endif /* MBED_DIRHANDLE_H */