D:/DRISSI/arduino-0022/arduino-0022/libraries/SD/File.cpp
00001 /*
00002 
00003  SD - a slightly more friendly wrapper for sdfatlib
00004 
00005  This library aims to expose a subset of SD card functionality
00006  in the form of a higher level "wrapper" object.
00007 
00008  License: GNU General Public License V3
00009           (Because sdfatlib is licensed with this.)
00010 
00011  (C) Copyright 2010 SparkFun Electronics
00012 
00013  */
00014 
00015 #include <SD.h>
00016 
00017 void File::write(uint8_t val) {
00018   SD.file.write(val);
00019 }
00020 
00021 void File::write(const char *str) {
00022   SD.file.write(str);
00023 }
00024 
00025 void File::write(const uint8_t *buf, size_t size) {
00026   SD.file.write(buf, size);
00027 }
00028 
00029 int File::peek() {
00030   char c = SD.file.read();
00031   if (c != -1) SD.file.seekCur(-1);
00032   return c;
00033 }
00034 
00035 int File::read() {
00036   return SD.file.read();
00037 }
00038 
00039 int File::available() {
00040   return size() - position();
00041 }
00042 
00043 void File::flush() {
00044   SD.file.sync();
00045 }
00046 
00047 boolean File::seek(uint32_t pos) {
00048   return SD.file.seekSet(pos);
00049 }
00050 
00051 uint32_t File::position() {
00052   return SD.file.curPosition();
00053 }
00054 
00055 uint32_t File::size() {
00056   return SD.file.fileSize();
00057 }
00058 
00059 void File::close() {
00060   SD.file.close();
00061 }
00062 
00063 File::operator bool() {
00064   return SD.file.isOpen();
00065 }