summaryrefslogtreecommitdiff
path: root/libraries/SD/File.cpp
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-10-20 22:16:19 -0700
committerJesse Morgan <jesse@jesterpm.net>2011-10-20 22:16:19 -0700
commitfc944ff979dbbd49a57722fe2d1d2acf47312eb4 (patch)
tree38cc3a5c5c8f24f55068fc4ffa73d018169fc2df /libraries/SD/File.cpp
Inital commit... halfway through the project
Diffstat (limited to 'libraries/SD/File.cpp')
-rw-r--r--libraries/SD/File.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/libraries/SD/File.cpp b/libraries/SD/File.cpp
new file mode 100644
index 0000000..af44bc7
--- /dev/null
+++ b/libraries/SD/File.cpp
@@ -0,0 +1,65 @@
+/*
+
+ 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);
+}
+
+int File::peek() {
+ char c = SD.file.read();
+ if (c != -1) SD.file.seekCur(-1);
+ return c;
+}
+
+int File::read() {
+ return SD.file.read();
+}
+
+int File::available() {
+ return size() - position();
+}
+
+void File::flush() {
+ SD.file.sync();
+}
+
+boolean File::seek(uint32_t pos) {
+ return SD.file.seekSet(pos);
+}
+
+uint32_t File::position() {
+ return SD.file.curPosition();
+}
+
+uint32_t File::size() {
+ return SD.file.fileSize();
+}
+
+void File::close() {
+ SD.file.close();
+}
+
+File::operator bool() {
+ return SD.file.isOpen();
+}