PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

73 lines
1.7KB

  1. /* Experimental File & Dir base classes. VERY experimental!
  2. These are intended to someday allow libraries using files,
  3. such as a JPEG decoder, to accept a File object from SD,
  4. Bridge, USB Host, ESP SPIFFS, and others. Perhaps only a
  5. distant dream at this point, but maybe someday....
  6. */
  7. #ifndef FS_H
  8. #define FS_H
  9. #ifdef __cplusplus
  10. #include "Stream.h"
  11. #include "WString.h"
  12. class File : public Stream {
  13. public:
  14. constexpr File() {}
  15. enum SeekMode {
  16. SeekSet = 0,
  17. SeekCur = 1,
  18. SeekEnd = 2
  19. };
  20. virtual size_t read(void *buf, size_t nbyte);
  21. virtual size_t write(const void *buf, size_t size);
  22. virtual int available();
  23. virtual int read();
  24. virtual int peek();
  25. virtual void flush();
  26. virtual bool seek(uint32_t pos, int mode);
  27. virtual uint32_t position() const;
  28. virtual uint32_t size() const;
  29. virtual void close();
  30. virtual operator bool() const;
  31. //virtual const char* name() const; // why does ESP have this in File?
  32. bool seek(uint32_t pos) {
  33. return seek(pos, SeekSet);
  34. }
  35. size_t write(uint8_t b) {
  36. return write(&b, 1);
  37. }
  38. size_t write(const char *str) {
  39. return write(str, strlen(str));
  40. }
  41. size_t readBytes(char *buffer, size_t length) {
  42. return read(buffer, length);
  43. }
  44. // needed for compatiblity with Arduino's SD & Bridge libs
  45. virtual const char* name();
  46. virtual bool isDirectory();
  47. virtual File openNextFile(uint8_t mode=0);
  48. virtual void rewindDirectory(void);
  49. };
  50. class Dir {
  51. public:
  52. constexpr Dir() {}
  53. virtual const char *name(); // from SD's File (and ESP's File)
  54. virtual uint32_t fileSize();
  55. virtual bool isDirectory(); // from SD, not in ESP
  56. virtual File openFile(const char *mode);
  57. virtual bool next();
  58. String fileName() {
  59. return String(name());
  60. }
  61. };
  62. #endif // __cplusplus
  63. #endif // FS_H