teste de publish

Dependencies:   DS1820 HighSpeedAnalogIn devices mbed

Committer:
brunofgc
Date:
Fri Jun 08 22:14:21 2018 +0000
Revision:
38:07d3907b74e5
Parent:
0:1c0a769988ee
teste de publish para compilar no mbed-cli

Who changed what in which revision?

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