|
-
-
- #ifndef __SD_H__
- #define __SD_H__
-
- #include <Arduino.h>
-
- #include <utility/SdFat.h>
- #include <utility/SdFatUtil.h>
-
- #define FILE_READ O_READ
- #define FILE_WRITE (O_READ | O_WRITE | O_CREAT)
-
- class File : public Stream {
- private:
- char _name[13];
- SdFile *_file;
-
- public:
- File(SdFile f, const char *name);
- File(void);
- ~File(void);
- virtual size_t write(uint8_t);
- virtual size_t write(const uint8_t *buf, size_t size);
- virtual int read();
- virtual int peek();
- virtual int available();
- virtual void flush();
- int read(void *buf, uint16_t nbyte);
- boolean seek(uint32_t pos);
- uint32_t position();
- uint32_t size();
- void close();
- operator bool();
- char * name();
-
- boolean isDirectory(void);
- File openNextFile(uint8_t mode = O_RDONLY);
- void rewindDirectory(void);
-
- using Print::write;
- };
-
- class SDClass {
-
- private:
-
- Sd2Card card;
- SdVolume volume;
- SdFile root;
-
-
- SdFile getParentDir(const char *filepath, int *indx);
- public:
-
-
- boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
-
-
-
-
- File open(const char *filename, uint8_t mode = FILE_READ);
-
-
- boolean exists(const char *filepath);
-
-
-
- boolean mkdir(const char *filepath);
-
-
- boolean remove(const char *filepath);
-
- boolean rmdir(const char *filepath);
-
- private:
-
-
-
-
-
-
- int fileOpenMode;
-
- friend class File;
- friend boolean callback_openPath(SdFile&, char *, boolean, void *);
- };
-
- extern SDClass SD;
-
- #endif
|