JEK changes enabling proper recording of IMU/GPS datastrams - 02-APR-2013
Fork of GPS_Incremental by
FatFileSystem/FATDirHandle.cpp@9:b45feb91ba38, 2013-04-19 (annotated)
- Committer:
- jekain314
- Date:
- Fri Apr 19 16:21:27 2013 +0000
- Revision:
- 9:b45feb91ba38
- Parent:
- 0:c746ee34feae
update to allow better imu gps data collection
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dannyman939 | 0:c746ee34feae | 1 | /* mbed Microcontroller Library - FATDirHandle |
dannyman939 | 0:c746ee34feae | 2 | * Copyright (c) 2008, sford |
dannyman939 | 0:c746ee34feae | 3 | */ |
dannyman939 | 0:c746ee34feae | 4 | |
dannyman939 | 0:c746ee34feae | 5 | #include <stdio.h> |
dannyman939 | 0:c746ee34feae | 6 | #include <stdlib.h> |
dannyman939 | 0:c746ee34feae | 7 | #include <string.h> |
dannyman939 | 0:c746ee34feae | 8 | #include "ff.h" |
dannyman939 | 0:c746ee34feae | 9 | #include "FATDirHandle.h" |
dannyman939 | 0:c746ee34feae | 10 | #include "FATFileSystem.h" |
dannyman939 | 0:c746ee34feae | 11 | |
dannyman939 | 0:c746ee34feae | 12 | namespace mbed { |
dannyman939 | 0:c746ee34feae | 13 | |
dannyman939 | 0:c746ee34feae | 14 | FATDirHandle::FATDirHandle(const FATFS_DIR &the_dir) { |
dannyman939 | 0:c746ee34feae | 15 | dir = the_dir; |
dannyman939 | 0:c746ee34feae | 16 | } |
dannyman939 | 0:c746ee34feae | 17 | |
dannyman939 | 0:c746ee34feae | 18 | int FATDirHandle::closedir() { |
dannyman939 | 0:c746ee34feae | 19 | delete this; |
dannyman939 | 0:c746ee34feae | 20 | return 0; |
dannyman939 | 0:c746ee34feae | 21 | } |
dannyman939 | 0:c746ee34feae | 22 | |
dannyman939 | 0:c746ee34feae | 23 | struct dirent *FATDirHandle::readdir() { |
dannyman939 | 0:c746ee34feae | 24 | FILINFO finfo; |
dannyman939 | 0:c746ee34feae | 25 | |
dannyman939 | 0:c746ee34feae | 26 | #if _USE_LFN |
dannyman939 | 0:c746ee34feae | 27 | finfo.lfname = cur_entry.d_name; |
dannyman939 | 0:c746ee34feae | 28 | finfo.lfsize = sizeof(cur_entry.d_name); |
dannyman939 | 0:c746ee34feae | 29 | #endif // _USE_LFN |
dannyman939 | 0:c746ee34feae | 30 | |
dannyman939 | 0:c746ee34feae | 31 | FRESULT res = f_readdir(&dir, &finfo); |
dannyman939 | 0:c746ee34feae | 32 | |
dannyman939 | 0:c746ee34feae | 33 | #if _USE_LFN |
dannyman939 | 0:c746ee34feae | 34 | if(res != 0 || finfo.fname[0]==0) { |
dannyman939 | 0:c746ee34feae | 35 | return NULL; |
dannyman939 | 0:c746ee34feae | 36 | } else { |
dannyman939 | 0:c746ee34feae | 37 | if(cur_entry.d_name[0]==0) { |
dannyman939 | 0:c746ee34feae | 38 | // No long filename so use short filename. |
dannyman939 | 0:c746ee34feae | 39 | memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname)); |
dannyman939 | 0:c746ee34feae | 40 | } |
dannyman939 | 0:c746ee34feae | 41 | return &cur_entry; |
dannyman939 | 0:c746ee34feae | 42 | } |
dannyman939 | 0:c746ee34feae | 43 | #else |
dannyman939 | 0:c746ee34feae | 44 | if(res != 0 || finfo.fname[0]==0) { |
dannyman939 | 0:c746ee34feae | 45 | return NULL; |
dannyman939 | 0:c746ee34feae | 46 | } else { |
dannyman939 | 0:c746ee34feae | 47 | memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname)); |
dannyman939 | 0:c746ee34feae | 48 | return &cur_entry; |
dannyman939 | 0:c746ee34feae | 49 | } |
dannyman939 | 0:c746ee34feae | 50 | #endif /* _USE_LFN */ |
dannyman939 | 0:c746ee34feae | 51 | } |
dannyman939 | 0:c746ee34feae | 52 | |
dannyman939 | 0:c746ee34feae | 53 | void FATDirHandle::rewinddir() { |
dannyman939 | 0:c746ee34feae | 54 | dir.index = 0; |
dannyman939 | 0:c746ee34feae | 55 | } |
dannyman939 | 0:c746ee34feae | 56 | |
dannyman939 | 0:c746ee34feae | 57 | off_t FATDirHandle::telldir() { |
dannyman939 | 0:c746ee34feae | 58 | return dir.index; |
dannyman939 | 0:c746ee34feae | 59 | } |
dannyman939 | 0:c746ee34feae | 60 | |
dannyman939 | 0:c746ee34feae | 61 | void FATDirHandle::seekdir(off_t location) { |
dannyman939 | 0:c746ee34feae | 62 | dir.index = location; |
dannyman939 | 0:c746ee34feae | 63 | } |
dannyman939 | 0:c746ee34feae | 64 | |
dannyman939 | 0:c746ee34feae | 65 | } |
dannyman939 | 0:c746ee34feae | 66 |