J&W / Mbed 2 deprecated Rejestrator

Dependencies:   mbed Rejestrator

Dependents:   Rejestrator

Committer:
Waldek
Date:
Sat May 09 15:06:38 2015 +0000
Revision:
1:5ad44a4edff9
Parent:
0:fa31f8461c63
Correction in the magnetic measurement

Who changed what in which revision?

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