Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
SDFileSystem/FATFileSystem/Interface/FATDirHandle.cpp@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | /* mbed Microcontroller Library - FATDirHandle |
shimniok | 0:826c6171fc1b | 2 | Copyright (c) 2008, sford */ |
shimniok | 0:826c6171fc1b | 3 | |
shimniok | 0:826c6171fc1b | 4 | //Modified by Thomas Hamilton, Copyright 2010 |
shimniok | 0:826c6171fc1b | 5 | |
shimniok | 0:826c6171fc1b | 6 | #include "FATDirHandle.h" |
shimniok | 0:826c6171fc1b | 7 | |
shimniok | 0:826c6171fc1b | 8 | FATDirHandle::FATDirHandle(FAT_DIR InputDirStr) |
shimniok | 0:826c6171fc1b | 9 | { |
shimniok | 0:826c6171fc1b | 10 | DirectoryObject = InputDirStr; |
shimniok | 0:826c6171fc1b | 11 | } |
shimniok | 0:826c6171fc1b | 12 | |
shimniok | 0:826c6171fc1b | 13 | int FATDirHandle::closedir() |
shimniok | 0:826c6171fc1b | 14 | { |
shimniok | 0:826c6171fc1b | 15 | delete this; |
shimniok | 0:826c6171fc1b | 16 | return 0; |
shimniok | 0:826c6171fc1b | 17 | } |
shimniok | 0:826c6171fc1b | 18 | |
shimniok | 0:826c6171fc1b | 19 | struct dirent* FATDirHandle::readdir() |
shimniok | 0:826c6171fc1b | 20 | { |
shimniok | 0:826c6171fc1b | 21 | FILINFO FileInfo; |
shimniok | 0:826c6171fc1b | 22 | FRESULT Result = f_readdir(&DirectoryObject, &FileInfo); |
shimniok | 0:826c6171fc1b | 23 | if (Result || !FileInfo.fname[0]) |
shimniok | 0:826c6171fc1b | 24 | { |
shimniok | 0:826c6171fc1b | 25 | return NULL; |
shimniok | 0:826c6171fc1b | 26 | } |
shimniok | 0:826c6171fc1b | 27 | else |
shimniok | 0:826c6171fc1b | 28 | { |
shimniok | 0:826c6171fc1b | 29 | for (unsigned char i = 0; i < 13; i++) |
shimniok | 0:826c6171fc1b | 30 | { |
shimniok | 0:826c6171fc1b | 31 | CurrentEntry.d_name[i] = ((char*)FileInfo.fname)[i]; |
shimniok | 0:826c6171fc1b | 32 | } |
shimniok | 0:826c6171fc1b | 33 | return &CurrentEntry; |
shimniok | 0:826c6171fc1b | 34 | } |
shimniok | 0:826c6171fc1b | 35 | } |
shimniok | 0:826c6171fc1b | 36 | |
shimniok | 0:826c6171fc1b | 37 | void FATDirHandle::rewinddir() |
shimniok | 0:826c6171fc1b | 38 | { |
shimniok | 0:826c6171fc1b | 39 | DirectoryObject.index = 0; |
shimniok | 0:826c6171fc1b | 40 | } |
shimniok | 0:826c6171fc1b | 41 | |
shimniok | 0:826c6171fc1b | 42 | off_t FATDirHandle::telldir() |
shimniok | 0:826c6171fc1b | 43 | { |
shimniok | 0:826c6171fc1b | 44 | return (off_t)DirectoryObject.index; |
shimniok | 0:826c6171fc1b | 45 | } |
shimniok | 0:826c6171fc1b | 46 | |
shimniok | 0:826c6171fc1b | 47 | void FATDirHandle::seekdir(off_t location) |
shimniok | 0:826c6171fc1b | 48 | { |
shimniok | 0:826c6171fc1b | 49 | DirectoryObject.index = (WORD)location; |
shimniok | 0:826c6171fc1b | 50 | } |