Updated get_fattime to use rtc and provide a date/time. This has been an annoying missing feature.
Dependents: IoTGateway_Basic y_XBeeTest_5_read CameraC1098_picture LifeCam ... more
FATDirHandle.cpp@1:5baba5d5b728, 2012-04-02 (annotated)
- Committer:
- SomeRandomBloke
- Date:
- Mon Apr 02 22:06:35 2012 +0000
- Revision:
- 1:5baba5d5b728
- Parent:
- 0:93acdd9f65f4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SomeRandomBloke | 0:93acdd9f65f4 | 1 | /* mbed Microcontroller Library - FATDirHandle |
SomeRandomBloke | 0:93acdd9f65f4 | 2 | * Copyright (c) 2008, sford |
SomeRandomBloke | 0:93acdd9f65f4 | 3 | */ |
SomeRandomBloke | 0:93acdd9f65f4 | 4 | |
SomeRandomBloke | 0:93acdd9f65f4 | 5 | #include <stdio.h> |
SomeRandomBloke | 0:93acdd9f65f4 | 6 | #include <stdlib.h> |
SomeRandomBloke | 0:93acdd9f65f4 | 7 | #include <string.h> |
SomeRandomBloke | 0:93acdd9f65f4 | 8 | #include "ff.h" |
SomeRandomBloke | 0:93acdd9f65f4 | 9 | #include "FATDirHandle.h" |
SomeRandomBloke | 0:93acdd9f65f4 | 10 | #include "FATFileSystem.h" |
SomeRandomBloke | 0:93acdd9f65f4 | 11 | |
SomeRandomBloke | 0:93acdd9f65f4 | 12 | namespace mbed { |
SomeRandomBloke | 0:93acdd9f65f4 | 13 | |
SomeRandomBloke | 0:93acdd9f65f4 | 14 | FATDirHandle::FATDirHandle(const FATFS_DIR &the_dir) { |
SomeRandomBloke | 0:93acdd9f65f4 | 15 | dir = the_dir; |
SomeRandomBloke | 0:93acdd9f65f4 | 16 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 17 | |
SomeRandomBloke | 0:93acdd9f65f4 | 18 | int FATDirHandle::closedir() { |
SomeRandomBloke | 0:93acdd9f65f4 | 19 | delete this; |
SomeRandomBloke | 0:93acdd9f65f4 | 20 | return 0; |
SomeRandomBloke | 0:93acdd9f65f4 | 21 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 22 | |
SomeRandomBloke | 0:93acdd9f65f4 | 23 | struct dirent *FATDirHandle::readdir() { |
SomeRandomBloke | 0:93acdd9f65f4 | 24 | FILINFO finfo; |
SomeRandomBloke | 0:93acdd9f65f4 | 25 | |
SomeRandomBloke | 0:93acdd9f65f4 | 26 | #if _USE_LFN |
SomeRandomBloke | 0:93acdd9f65f4 | 27 | finfo.lfname = cur_entry.d_name; |
SomeRandomBloke | 0:93acdd9f65f4 | 28 | finfo.lfsize = sizeof(cur_entry.d_name); |
SomeRandomBloke | 0:93acdd9f65f4 | 29 | #endif // _USE_LFN |
SomeRandomBloke | 0:93acdd9f65f4 | 30 | |
SomeRandomBloke | 0:93acdd9f65f4 | 31 | FRESULT res = f_readdir(&dir, &finfo); |
SomeRandomBloke | 0:93acdd9f65f4 | 32 | |
SomeRandomBloke | 0:93acdd9f65f4 | 33 | #if _USE_LFN |
SomeRandomBloke | 0:93acdd9f65f4 | 34 | if(res != 0 || finfo.fname[0]==0) { |
SomeRandomBloke | 0:93acdd9f65f4 | 35 | return NULL; |
SomeRandomBloke | 0:93acdd9f65f4 | 36 | } else { |
SomeRandomBloke | 0:93acdd9f65f4 | 37 | if(cur_entry.d_name[0]==0) { |
SomeRandomBloke | 0:93acdd9f65f4 | 38 | // No long filename so use short filename. |
SomeRandomBloke | 0:93acdd9f65f4 | 39 | memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname)); |
SomeRandomBloke | 0:93acdd9f65f4 | 40 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 41 | return &cur_entry; |
SomeRandomBloke | 0:93acdd9f65f4 | 42 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 43 | #else |
SomeRandomBloke | 0:93acdd9f65f4 | 44 | if(res != 0 || finfo.fname[0]==0) { |
SomeRandomBloke | 0:93acdd9f65f4 | 45 | return NULL; |
SomeRandomBloke | 0:93acdd9f65f4 | 46 | } else { |
SomeRandomBloke | 0:93acdd9f65f4 | 47 | memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname)); |
SomeRandomBloke | 0:93acdd9f65f4 | 48 | return &cur_entry; |
SomeRandomBloke | 0:93acdd9f65f4 | 49 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 50 | #endif /* _USE_LFN */ |
SomeRandomBloke | 0:93acdd9f65f4 | 51 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 52 | |
SomeRandomBloke | 0:93acdd9f65f4 | 53 | void FATDirHandle::rewinddir() { |
SomeRandomBloke | 0:93acdd9f65f4 | 54 | dir.index = 0; |
SomeRandomBloke | 0:93acdd9f65f4 | 55 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 56 | |
SomeRandomBloke | 0:93acdd9f65f4 | 57 | off_t FATDirHandle::telldir() { |
SomeRandomBloke | 0:93acdd9f65f4 | 58 | return dir.index; |
SomeRandomBloke | 0:93acdd9f65f4 | 59 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 60 | |
SomeRandomBloke | 0:93acdd9f65f4 | 61 | void FATDirHandle::seekdir(off_t location) { |
SomeRandomBloke | 0:93acdd9f65f4 | 62 | dir.index = location; |
SomeRandomBloke | 0:93acdd9f65f4 | 63 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 64 | |
SomeRandomBloke | 0:93acdd9f65f4 | 65 | } |
SomeRandomBloke | 0:93acdd9f65f4 | 66 |