|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
-
-
-
- #ifndef FS_H
- #define FS_H
- #ifdef __cplusplus
-
- #include "Stream.h"
- #include "WString.h"
-
- class File : public Stream {
- public:
- constexpr File() {}
- enum SeekMode {
- SeekSet = 0,
- SeekCur = 1,
- SeekEnd = 2
- };
- virtual size_t read(void *buf, size_t nbyte);
- virtual size_t write(const void *buf, size_t size);
- virtual int available();
- virtual int read();
- virtual int peek();
- virtual void flush();
- virtual bool seek(uint32_t pos, int mode);
- virtual uint32_t position() const;
- virtual uint32_t size() const;
- virtual void close();
- virtual operator bool() const;
-
-
- bool seek(uint32_t pos) {
- return seek(pos, SeekSet);
- }
- size_t write(uint8_t b) {
- return write(&b, 1);
- }
- size_t write(const char *str) {
- return write(str, strlen(str));
- }
- size_t readBytes(char *buffer, size_t length) {
- return read(buffer, length);
- }
-
-
- virtual const char* name();
- virtual bool isDirectory();
- virtual File openNextFile(uint8_t mode=0);
- virtual void rewindDirectory(void);
- };
-
- class Dir {
- public:
- constexpr Dir() {}
- virtual const char *name();
- virtual uint32_t fileSize();
- virtual bool isDirectory();
- virtual File openFile(const char *mode);
- virtual bool next();
- String fileName() {
- return String(name());
- }
- };
-
- #endif
- #endif
|