From 1ea21ee38a9155a9029f53712f4f369884cfbb94 Mon Sep 17 00:00:00 2001
From: Cristian Maglie <c.maglie@bug.st>
Date: Mon, 10 Jun 2013 11:50:00 +0200
Subject: Implemented FileIO.position()

---
 libraries/Bridge/FileIO.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'libraries/Bridge')

diff --git a/libraries/Bridge/FileIO.cpp b/libraries/Bridge/FileIO.cpp
index bd8f487..c66f937 100644
--- a/libraries/Bridge/FileIO.cpp
+++ b/libraries/Bridge/FileIO.cpp
@@ -96,6 +96,18 @@ boolean File::seek(uint32_t position) {
   return false;
 }
 
+uint32_t File::position() {
+  uint8_t cmd[] = {'S', handle};
+  uint8_t res[5];
+  bridge.transfer(cmd, 2, res, 5);
+  //err = res[0]; // res[0] contains error code
+  uint32_t pos = res[1] << 24;
+  pos += res[2] << 16;
+  pos += res[3] << 8;
+  pos += res[4];
+  return pos - buffered;
+}
+
 void File::doBuffer() {
   // If there are already char in buffer exit
   if (buffered > 0)
@@ -124,7 +136,6 @@ void File::flush() {
 
 //int read(void *buf, uint16_t nbyte)
 
-//uint32_t position()
 //uint32_t size()
 
 void File::close() {
-- 
cgit v1.2.3-18-g5258