2010-11-20 04:30:40 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
SD - a slightly more friendly wrapper for sdfatlib
|
|
|
|
|
|
|
|
This library aims to expose a subset of SD card functionality
|
|
|
|
in the form of a higher level "wrapper" object.
|
|
|
|
|
|
|
|
License: GNU General Public License V3
|
|
|
|
(Because sdfatlib is licensed with this.)
|
|
|
|
|
|
|
|
(C) Copyright 2010 SparkFun Electronics
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <SD.h>
|
|
|
|
|
|
|
|
void File::write(uint8_t val) {
|
|
|
|
SD.file.write(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void File::write(const char *str) {
|
|
|
|
SD.file.write(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void File::write(const uint8_t *buf, size_t size) {
|
|
|
|
SD.file.write(buf, size);
|
|
|
|
}
|
|
|
|
|
2010-11-20 17:45:05 +01:00
|
|
|
int File::peek() {
|
2010-12-22 23:47:50 +01:00
|
|
|
char c = SD.file.read();
|
|
|
|
if (c != -1) SD.file.seekCur(-1);
|
|
|
|
return c;
|
2010-11-20 17:45:05 +01:00
|
|
|
}
|
|
|
|
|
2010-11-20 04:30:40 +01:00
|
|
|
int File::read() {
|
|
|
|
return SD.file.read();
|
|
|
|
}
|
|
|
|
|
2010-11-20 17:45:05 +01:00
|
|
|
int File::available() {
|
2010-12-22 23:47:50 +01:00
|
|
|
return size() - position();
|
2010-11-20 17:45:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void File::flush() {
|
|
|
|
SD.file.sync();
|
|
|
|
}
|
|
|
|
|
2010-12-22 22:11:54 +01:00
|
|
|
boolean File::seek(uint32_t pos) {
|
|
|
|
return SD.file.seekSet(pos);
|
|
|
|
}
|
|
|
|
|
2010-12-22 22:52:09 +01:00
|
|
|
uint32_t File::position() {
|
|
|
|
return SD.file.curPosition();
|
|
|
|
}
|
|
|
|
|
2010-12-22 22:11:54 +01:00
|
|
|
uint32_t File::size() {
|
|
|
|
return SD.file.fileSize();
|
|
|
|
}
|
|
|
|
|
2010-11-20 04:30:40 +01:00
|
|
|
void File::close() {
|
|
|
|
SD.file.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
File::operator bool() {
|
|
|
|
return SD.file.isOpen();
|
|
|
|
}
|