![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Dependencies: PinDetect TextLCD mbed mRotaryEncoder
FATFileSystem/Interface/FATDirHandle.cpp@0:afb2650fb49a, 2012-02-13 (annotated)
- Committer:
- cicklaus
- Date:
- Mon Feb 13 02:11:20 2012 +0000
- Revision:
- 0:afb2650fb49a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cicklaus | 0:afb2650fb49a | 1 | /* mbed Microcontroller Library - FATDirHandle |
cicklaus | 0:afb2650fb49a | 2 | Copyright (c) 2008, sford */ |
cicklaus | 0:afb2650fb49a | 3 | |
cicklaus | 0:afb2650fb49a | 4 | //Modified by Thomas Hamilton, Copyright 2010 |
cicklaus | 0:afb2650fb49a | 5 | |
cicklaus | 0:afb2650fb49a | 6 | #include "FATDirHandle.h" |
cicklaus | 0:afb2650fb49a | 7 | |
cicklaus | 0:afb2650fb49a | 8 | FATDirHandle::FATDirHandle(FAT_DIR InputDirStr) |
cicklaus | 0:afb2650fb49a | 9 | { |
cicklaus | 0:afb2650fb49a | 10 | DirectoryObject = InputDirStr; |
cicklaus | 0:afb2650fb49a | 11 | } |
cicklaus | 0:afb2650fb49a | 12 | |
cicklaus | 0:afb2650fb49a | 13 | int FATDirHandle::closedir() |
cicklaus | 0:afb2650fb49a | 14 | { |
cicklaus | 0:afb2650fb49a | 15 | delete this; |
cicklaus | 0:afb2650fb49a | 16 | return 0; |
cicklaus | 0:afb2650fb49a | 17 | } |
cicklaus | 0:afb2650fb49a | 18 | |
cicklaus | 0:afb2650fb49a | 19 | struct dirent* FATDirHandle::readdir() |
cicklaus | 0:afb2650fb49a | 20 | { |
cicklaus | 0:afb2650fb49a | 21 | FILINFO FileInfo; |
cicklaus | 0:afb2650fb49a | 22 | FRESULT Result = f_readdir(&DirectoryObject, &FileInfo); |
cicklaus | 0:afb2650fb49a | 23 | if (Result || !FileInfo.fname[0]) |
cicklaus | 0:afb2650fb49a | 24 | { |
cicklaus | 0:afb2650fb49a | 25 | return NULL; |
cicklaus | 0:afb2650fb49a | 26 | } |
cicklaus | 0:afb2650fb49a | 27 | else |
cicklaus | 0:afb2650fb49a | 28 | { |
cicklaus | 0:afb2650fb49a | 29 | for (unsigned char i = 0; i < 13; i++) |
cicklaus | 0:afb2650fb49a | 30 | { |
cicklaus | 0:afb2650fb49a | 31 | CurrentEntry.d_name[i] = ((char*)FileInfo.fname)[i]; |
cicklaus | 0:afb2650fb49a | 32 | } |
cicklaus | 0:afb2650fb49a | 33 | return &CurrentEntry; |
cicklaus | 0:afb2650fb49a | 34 | } |
cicklaus | 0:afb2650fb49a | 35 | } |
cicklaus | 0:afb2650fb49a | 36 | |
cicklaus | 0:afb2650fb49a | 37 | void FATDirHandle::rewinddir() |
cicklaus | 0:afb2650fb49a | 38 | { |
cicklaus | 0:afb2650fb49a | 39 | DirectoryObject.index = 0; |
cicklaus | 0:afb2650fb49a | 40 | } |
cicklaus | 0:afb2650fb49a | 41 | |
cicklaus | 0:afb2650fb49a | 42 | off_t FATDirHandle::telldir() |
cicklaus | 0:afb2650fb49a | 43 | { |
cicklaus | 0:afb2650fb49a | 44 | return (off_t)DirectoryObject.index; |
cicklaus | 0:afb2650fb49a | 45 | } |
cicklaus | 0:afb2650fb49a | 46 | |
cicklaus | 0:afb2650fb49a | 47 | void FATDirHandle::seekdir(off_t location) |
cicklaus | 0:afb2650fb49a | 48 | { |
cicklaus | 0:afb2650fb49a | 49 | DirectoryObject.index = (WORD)location; |
cicklaus | 0:afb2650fb49a | 50 | } |