ロケット用プログラム
Dependencies: mbed
SDFileSystem/FATFileSystem/FATDirHandle.cpp@0:d58274531d38, 2019-09-11 (annotated)
- Committer:
- ishiyamayuto
- Date:
- Wed Sep 11 06:37:20 2019 +0000
- Revision:
- 0:d58274531d38
BMP180,MPU6050
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ishiyamayuto | 0:d58274531d38 | 1 | /* mbed Microcontroller Library |
ishiyamayuto | 0:d58274531d38 | 2 | * Copyright (c) 2006-2012 ARM Limited |
ishiyamayuto | 0:d58274531d38 | 3 | * |
ishiyamayuto | 0:d58274531d38 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
ishiyamayuto | 0:d58274531d38 | 5 | * of this software and associated documentation files (the "Software"), to deal |
ishiyamayuto | 0:d58274531d38 | 6 | * in the Software without restriction, including without limitation the rights |
ishiyamayuto | 0:d58274531d38 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
ishiyamayuto | 0:d58274531d38 | 8 | * copies of the Software, and to permit persons to whom the Software is |
ishiyamayuto | 0:d58274531d38 | 9 | * furnished to do so, subject to the following conditions: |
ishiyamayuto | 0:d58274531d38 | 10 | * |
ishiyamayuto | 0:d58274531d38 | 11 | * The above copyright notice and this permission notice shall be included in |
ishiyamayuto | 0:d58274531d38 | 12 | * all copies or substantial portions of the Software. |
ishiyamayuto | 0:d58274531d38 | 13 | * |
ishiyamayuto | 0:d58274531d38 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
ishiyamayuto | 0:d58274531d38 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
ishiyamayuto | 0:d58274531d38 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
ishiyamayuto | 0:d58274531d38 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
ishiyamayuto | 0:d58274531d38 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ishiyamayuto | 0:d58274531d38 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
ishiyamayuto | 0:d58274531d38 | 20 | * SOFTWARE. |
ishiyamayuto | 0:d58274531d38 | 21 | */ |
ishiyamayuto | 0:d58274531d38 | 22 | #include <string.h> |
ishiyamayuto | 0:d58274531d38 | 23 | #include "ff.h" |
ishiyamayuto | 0:d58274531d38 | 24 | #include "FATDirHandle.h" |
ishiyamayuto | 0:d58274531d38 | 25 | |
ishiyamayuto | 0:d58274531d38 | 26 | using namespace mbed; |
ishiyamayuto | 0:d58274531d38 | 27 | |
ishiyamayuto | 0:d58274531d38 | 28 | FATDirHandle::FATDirHandle(const FATFS_DIR &the_dir) { |
ishiyamayuto | 0:d58274531d38 | 29 | dir = the_dir; |
ishiyamayuto | 0:d58274531d38 | 30 | } |
ishiyamayuto | 0:d58274531d38 | 31 | |
ishiyamayuto | 0:d58274531d38 | 32 | int FATDirHandle::closedir() { |
ishiyamayuto | 0:d58274531d38 | 33 | int retval = f_closedir(&dir); |
ishiyamayuto | 0:d58274531d38 | 34 | delete this; |
ishiyamayuto | 0:d58274531d38 | 35 | return retval; |
ishiyamayuto | 0:d58274531d38 | 36 | } |
ishiyamayuto | 0:d58274531d38 | 37 | |
ishiyamayuto | 0:d58274531d38 | 38 | struct dirent *FATDirHandle::readdir() { |
ishiyamayuto | 0:d58274531d38 | 39 | FILINFO finfo; |
ishiyamayuto | 0:d58274531d38 | 40 | |
ishiyamayuto | 0:d58274531d38 | 41 | #if _USE_LFN |
ishiyamayuto | 0:d58274531d38 | 42 | finfo.lfname = cur_entry.d_name; |
ishiyamayuto | 0:d58274531d38 | 43 | finfo.lfsize = sizeof(cur_entry.d_name); |
ishiyamayuto | 0:d58274531d38 | 44 | #endif // _USE_LFN |
ishiyamayuto | 0:d58274531d38 | 45 | |
ishiyamayuto | 0:d58274531d38 | 46 | FRESULT res = f_readdir(&dir, &finfo); |
ishiyamayuto | 0:d58274531d38 | 47 | |
ishiyamayuto | 0:d58274531d38 | 48 | #if _USE_LFN |
ishiyamayuto | 0:d58274531d38 | 49 | if(res != 0 || finfo.fname[0]==0) { |
ishiyamayuto | 0:d58274531d38 | 50 | return NULL; |
ishiyamayuto | 0:d58274531d38 | 51 | } else { |
ishiyamayuto | 0:d58274531d38 | 52 | if(cur_entry.d_name[0]==0) { |
ishiyamayuto | 0:d58274531d38 | 53 | // No long filename so use short filename. |
ishiyamayuto | 0:d58274531d38 | 54 | memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname)); |
ishiyamayuto | 0:d58274531d38 | 55 | } |
ishiyamayuto | 0:d58274531d38 | 56 | return &cur_entry; |
ishiyamayuto | 0:d58274531d38 | 57 | } |
ishiyamayuto | 0:d58274531d38 | 58 | #else |
ishiyamayuto | 0:d58274531d38 | 59 | if(res != 0 || finfo.fname[0]==0) { |
ishiyamayuto | 0:d58274531d38 | 60 | return NULL; |
ishiyamayuto | 0:d58274531d38 | 61 | } else { |
ishiyamayuto | 0:d58274531d38 | 62 | memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname)); |
ishiyamayuto | 0:d58274531d38 | 63 | return &cur_entry; |
ishiyamayuto | 0:d58274531d38 | 64 | } |
ishiyamayuto | 0:d58274531d38 | 65 | #endif /* _USE_LFN */ |
ishiyamayuto | 0:d58274531d38 | 66 | } |
ishiyamayuto | 0:d58274531d38 | 67 | |
ishiyamayuto | 0:d58274531d38 | 68 | void FATDirHandle::rewinddir() { |
ishiyamayuto | 0:d58274531d38 | 69 | dir.index = 0; |
ishiyamayuto | 0:d58274531d38 | 70 | } |
ishiyamayuto | 0:d58274531d38 | 71 | |
ishiyamayuto | 0:d58274531d38 | 72 | off_t FATDirHandle::telldir() { |
ishiyamayuto | 0:d58274531d38 | 73 | return dir.index; |
ishiyamayuto | 0:d58274531d38 | 74 | } |
ishiyamayuto | 0:d58274531d38 | 75 | |
ishiyamayuto | 0:d58274531d38 | 76 | void FATDirHandle::seekdir(off_t location) { |
ishiyamayuto | 0:d58274531d38 | 77 | dir.index = location; |
ishiyamayuto | 0:d58274531d38 | 78 | } |
ishiyamayuto | 0:d58274531d38 | 79 |