Simon Ford
/
fat
FATDirHandle.cpp@1:208803a150b2, 2012-01-12 (annotated)
- Committer:
- simon
- Date:
- Thu Jan 12 12:59:33 2012 +0000
- Revision:
- 1:208803a150b2
- Parent:
- 0:560a6744936c
fix on line 61 of diskio, sector -> s
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:560a6744936c | 1 | /* mbed Microcontroller Library - FATDirHandle |
simon | 0:560a6744936c | 2 | * Copyright (c) 2008, sford |
simon | 0:560a6744936c | 3 | */ |
simon | 0:560a6744936c | 4 | |
simon | 0:560a6744936c | 5 | #include <stdio.h> |
simon | 0:560a6744936c | 6 | #include <stdlib.h> |
simon | 0:560a6744936c | 7 | #include <string.h> |
simon | 0:560a6744936c | 8 | #include "ff.h" |
simon | 0:560a6744936c | 9 | #include "FATDirHandle.h" |
simon | 0:560a6744936c | 10 | #include "FATFileSystem.h" |
simon | 0:560a6744936c | 11 | |
simon | 0:560a6744936c | 12 | namespace mbed { |
simon | 0:560a6744936c | 13 | |
simon | 0:560a6744936c | 14 | FATDirHandle::FATDirHandle(const FATFS_DIR &the_dir) { |
simon | 0:560a6744936c | 15 | dir = the_dir; |
simon | 0:560a6744936c | 16 | } |
simon | 0:560a6744936c | 17 | |
simon | 0:560a6744936c | 18 | int FATDirHandle::closedir() { |
simon | 0:560a6744936c | 19 | delete this; |
simon | 0:560a6744936c | 20 | return 0; |
simon | 0:560a6744936c | 21 | } |
simon | 0:560a6744936c | 22 | |
simon | 0:560a6744936c | 23 | struct dirent *FATDirHandle::readdir() { |
simon | 0:560a6744936c | 24 | FILINFO finfo; |
simon | 0:560a6744936c | 25 | FRESULT res = f_readdir(&dir, &finfo); |
simon | 0:560a6744936c | 26 | if(res != 0 || finfo.fname[0]==0) { |
simon | 0:560a6744936c | 27 | return NULL; |
simon | 0:560a6744936c | 28 | } else { |
simon | 0:560a6744936c | 29 | memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname)); |
simon | 0:560a6744936c | 30 | return &cur_entry; |
simon | 0:560a6744936c | 31 | } |
simon | 0:560a6744936c | 32 | } |
simon | 0:560a6744936c | 33 | |
simon | 0:560a6744936c | 34 | void FATDirHandle::rewinddir() { |
simon | 0:560a6744936c | 35 | dir.index = 0; |
simon | 0:560a6744936c | 36 | } |
simon | 0:560a6744936c | 37 | |
simon | 0:560a6744936c | 38 | off_t FATDirHandle::telldir() { |
simon | 0:560a6744936c | 39 | return dir.index; |
simon | 0:560a6744936c | 40 | } |
simon | 0:560a6744936c | 41 | |
simon | 0:560a6744936c | 42 | void FATDirHandle::seekdir(off_t location) { |
simon | 0:560a6744936c | 43 | dir.index = location; |
simon | 0:560a6744936c | 44 | } |
simon | 0:560a6744936c | 45 | |
simon | 0:560a6744936c | 46 | } |
simon | 0:560a6744936c | 47 |