Example SDFileSystem in which FATDirHandle exposes the file info struct of the current file/directory.

Revision:
1:a7d8fc28a863
Parent:
0:687056ba3278
--- a/SDFileSystem.cpp	Wed Sep 04 00:32:19 2013 +0000
+++ b/SDFileSystem.cpp	Fri Nov 28 05:12:38 2014 +0000
@@ -19,6 +19,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+
 /* Introduction
  * ------------
  * SD and MMC cards support a number of interfaces, but common to them all
@@ -133,14 +134,10 @@
 #define R1_PARAMETER_ERROR      (1 << 6)
 
 // Types
-//  - v1.x Standard Capacity
-//  - v2.x Standard Capacity
-//  - v2.x High Capacity
-//  - Not recognised as an SD Card
-#define SDCARD_FAIL 0
-#define SDCARD_V1   1
-#define SDCARD_V2   2
-#define SDCARD_V2HC 3
+#define SDCARD_FAIL 0 //!< v1.x Standard Capacity
+#define SDCARD_V1   1 //!< v2.x Standard Capacity
+#define SDCARD_V2   2 //!< v2.x High Capacity
+#define SDCARD_V2HC 3 //!< Not recognised as an SD Card
 
 int SDFileSystem::initialise_card() {
     // Set to 100kHz for initialisation, and clock card with cs = 1
@@ -150,22 +147,23 @@
         _spi.write(0xFF);
     }
     
+    int ret = SDCARD_FAIL;
+    
     // send CMD0, should return with all zeros except IDLE STATE set (bit 0)
     if (_cmd(0, 0) != R1_IDLE_STATE) {
         debug("No disk, or could not put SD card in to SPI idle state\n");
-        return SDCARD_FAIL;
     }
     
     // send CMD8 to determine whther it is ver 2.x
     int r = _cmd8();
     if (r == R1_IDLE_STATE) {
-        return initialise_card_v2();
+        ret = initialise_card_v2();
     } else if (r == (R1_IDLE_STATE | R1_ILLEGAL_COMMAND)) {
-        return initialise_card_v1();
+        ret = initialise_card_v1();
     } else {
         debug("Not in idle state after sending CMD8 (not an SD card?)\n");
-        return SDCARD_FAIL;
     }
+    return ret;
 }
 
 int SDFileSystem::initialise_card_v1() {
@@ -202,6 +200,9 @@
 int SDFileSystem::disk_initialize() {
     int i = initialise_card();
     debug_if(SD_DBG, "init card = %d\n", i);
+    if (i==SDCARD_FAIL) {
+        return 1;
+    }
     _sectors = _sd_sectors();
     
     // Set block length to 512 (CMD16)