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