SD Card Interface class. Log raw data bytes to memory addresses of your choice, or format the card and use the FAT file system to write files.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FATDirHandle.cpp Source File

FATDirHandle.cpp

00001 /* mbed Microcontroller Library - FATDirHandle
00002    Copyright (c) 2008, sford */
00003 
00004 //Modified by Thomas Hamilton, Copyright 2010
00005  
00006 #include "FATDirHandle.h"
00007 
00008 FATDirHandle::FATDirHandle(FAT_DIR InputDirStr)
00009 {
00010     DirectoryObject = InputDirStr;
00011 }
00012 
00013 int FATDirHandle::closedir()
00014 {
00015     delete this;
00016     return 0;
00017 }
00018 
00019 struct dirent* FATDirHandle::readdir()
00020 {
00021     FILINFO FileInfo;
00022     FRESULT Result = f_readdir(&DirectoryObject, &FileInfo);
00023     if (Result || !FileInfo.fname[0])
00024     {
00025         return NULL;
00026     }
00027     else
00028     {
00029         for (unsigned char i = 0; i < 13; i++)
00030         {
00031             CurrentEntry.d_name[i] = ((char*)FileInfo.fname)[i];
00032         }
00033         return &CurrentEntry;
00034     }
00035 }
00036 
00037 void FATDirHandle::rewinddir()
00038 {
00039     DirectoryObject.index = 0;
00040 }
00041 
00042 off_t FATDirHandle::telldir()
00043 {
00044     return (off_t)DirectoryObject.index;
00045 }
00046 
00047 void FATDirHandle::seekdir(off_t location)
00048 {
00049     DirectoryObject.index = (WORD)location;
00050 }