|
-
-
- #ifndef ArduinoFiles_h
- #define ArduinoFiles_h
- #include "FatLibConfig.h"
- #if ENABLE_ARDUINO_FEATURES
- #include "FatFile.h"
- #include <limits.h>
-
-
- #define FILE_READ O_READ
-
- #define FILE_WRITE (O_RDWR | O_CREAT | O_AT_END)
-
-
- class PrintFile : public FatFile, public Print {
- public:
- PrintFile() {}
-
-
- PrintFile(const char* path, uint8_t oflag) : FatFile(path, oflag) {}
- #if DESTRUCTOR_CLOSES_FILE
- ~PrintFile() {}
- #endif
- using FatFile::clearWriteError;
- using FatFile::getWriteError;
- using FatFile::read;
- using FatFile::write;
-
-
- int available() {
- uint32_t n = FatFile::available();
- return n > INT_MAX ? INT_MAX : n;
- }
-
- void flush() {
- FatFile::sync();
- }
-
-
- int peek() {
- return FatFile::peek();
- }
-
-
-
-
-
-
-
- size_t write(uint8_t b) {
- return FatFile::write(b);
- }
-
-
- size_t write(const uint8_t *buf, size_t size) {
- return FatFile::write(buf, size);
- }
- };
-
-
- #if ARDUINO_FILE_USES_STREAM
- class File : public FatFile, public Stream {
- #else
- class File : public FatFile, public Print {
- #endif
- public:
- File() {}
-
-
- File(const char* path, uint8_t oflag) {
- open(path, oflag);
- }
- using FatFile::clearWriteError;
- using FatFile::getWriteError;
- using FatFile::read;
- using FatFile::write;
-
-
- operator bool() {
- return isOpen();
- }
-
-
- int available() {
- uint32_t n = FatFile::available();
- return n > INT_MAX ? INT_MAX : n;
- }
-
- void flush() {
- FatFile::sync();
- }
-
-
- bool isDirectory() {
- return isDir();
- }
-
-
- const char* name() const {
- return "use getName()";
- }
-
-
- int peek() {
- return FatFile::peek();
- }
-
- uint32_t position() {
- return curPosition();
- }
-
-
- File openNextFile(uint8_t mode = O_READ) {
- File tmpFile;
- tmpFile.openNext(this, mode);
- return tmpFile;
- }
-
-
- int read() {
- return FatFile::read();
- }
-
- void rewindDirectory() {
- if (isDir()) {
- rewind();
- }
- }
-
-
- bool seek(uint32_t pos) {
- return seekSet(pos);
- }
-
- uint32_t size() {
- return fileSize();
- }
-
-
- size_t write(uint8_t b) {
- return FatFile::write(b);
- }
-
-
- size_t write(const uint8_t *buf, size_t size) {
- return FatFile::write(buf, size);
- }
- };
- #endif
- #endif
|