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.
FATFileSystem/Interface/FATDirHandle.cpp@1:94c648931f84, 2010-08-07 (annotated)
- Committer:
- Blaze513
- Date:
- Sat Aug 07 18:32:30 2010 +0000
- Revision:
- 1:94c648931f84
- Child:
- 3:210eb67b260c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Blaze513 | 1:94c648931f84 | 1 | /* mbed Microcontroller Library - FATDirHandle |
Blaze513 | 1:94c648931f84 | 2 | Copyright (c) 2008, sford */ |
Blaze513 | 1:94c648931f84 | 3 | |
Blaze513 | 1:94c648931f84 | 4 | #include "FATDirHandle.h" |
Blaze513 | 1:94c648931f84 | 5 | |
Blaze513 | 1:94c648931f84 | 6 | FATDirHandle::FATDirHandle(FAT_DIR InputDirStr) |
Blaze513 | 1:94c648931f84 | 7 | { |
Blaze513 | 1:94c648931f84 | 8 | DirectoryObject = InputDirStr; |
Blaze513 | 1:94c648931f84 | 9 | } |
Blaze513 | 1:94c648931f84 | 10 | |
Blaze513 | 1:94c648931f84 | 11 | int FATDirHandle::closedir() |
Blaze513 | 1:94c648931f84 | 12 | { |
Blaze513 | 1:94c648931f84 | 13 | delete this; |
Blaze513 | 1:94c648931f84 | 14 | return 0; |
Blaze513 | 1:94c648931f84 | 15 | } |
Blaze513 | 1:94c648931f84 | 16 | |
Blaze513 | 1:94c648931f84 | 17 | struct dirent* FATDirHandle::readdir() |
Blaze513 | 1:94c648931f84 | 18 | { |
Blaze513 | 1:94c648931f84 | 19 | FILINFO FileInfo; |
Blaze513 | 1:94c648931f84 | 20 | FRESULT Result = f_readdir(&DirectoryObject, &FileInfo); |
Blaze513 | 1:94c648931f84 | 21 | if (Result || !FileInfo.fname[0]) |
Blaze513 | 1:94c648931f84 | 22 | { |
Blaze513 | 1:94c648931f84 | 23 | return NULL; |
Blaze513 | 1:94c648931f84 | 24 | } |
Blaze513 | 1:94c648931f84 | 25 | else |
Blaze513 | 1:94c648931f84 | 26 | { |
Blaze513 | 1:94c648931f84 | 27 | for (unsigned char i = 0; i < 13; i++) |
Blaze513 | 1:94c648931f84 | 28 | { |
Blaze513 | 1:94c648931f84 | 29 | CurrentEntry.d_name[i] = ((char*)FileInfo.fname)[i]; |
Blaze513 | 1:94c648931f84 | 30 | } |
Blaze513 | 1:94c648931f84 | 31 | return &CurrentEntry; |
Blaze513 | 1:94c648931f84 | 32 | } |
Blaze513 | 1:94c648931f84 | 33 | } |
Blaze513 | 1:94c648931f84 | 34 | |
Blaze513 | 1:94c648931f84 | 35 | void FATDirHandle::rewinddir() |
Blaze513 | 1:94c648931f84 | 36 | { |
Blaze513 | 1:94c648931f84 | 37 | DirectoryObject.index = 0; |
Blaze513 | 1:94c648931f84 | 38 | } |
Blaze513 | 1:94c648931f84 | 39 | |
Blaze513 | 1:94c648931f84 | 40 | off_t FATDirHandle::telldir() |
Blaze513 | 1:94c648931f84 | 41 | { |
Blaze513 | 1:94c648931f84 | 42 | return (off_t)DirectoryObject.index; |
Blaze513 | 1:94c648931f84 | 43 | } |
Blaze513 | 1:94c648931f84 | 44 | |
Blaze513 | 1:94c648931f84 | 45 | void FATDirHandle::seekdir(off_t location) |
Blaze513 | 1:94c648931f84 | 46 | { |
Blaze513 | 1:94c648931f84 | 47 | DirectoryObject.index = (WORD)location; |
Blaze513 | 1:94c648931f84 | 48 | } |