Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:3a9487d57a5c 1 /* mbed Microcontroller Library
thedo 166:3a9487d57a5c 2 * Copyright (c) 2015 ARM Limited
thedo 166:3a9487d57a5c 3 *
thedo 166:3a9487d57a5c 4 * Licensed under the Apache License, Version 2.0 (the "License");
thedo 166:3a9487d57a5c 5 * you may not use this file except in compliance with the License.
thedo 166:3a9487d57a5c 6 * You may obtain a copy of the License at
thedo 166:3a9487d57a5c 7 *
thedo 166:3a9487d57a5c 8 * http://www.apache.org/licenses/LICENSE-2.0
thedo 166:3a9487d57a5c 9 *
thedo 166:3a9487d57a5c 10 * Unless required by applicable law or agreed to in writing, software
thedo 166:3a9487d57a5c 11 * distributed under the License is distributed on an "AS IS" BASIS,
thedo 166:3a9487d57a5c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
thedo 166:3a9487d57a5c 13 * See the License for the specific language governing permissions and
thedo 166:3a9487d57a5c 14 * limitations under the License.
thedo 166:3a9487d57a5c 15 */
thedo 166:3a9487d57a5c 16
thedo 166:3a9487d57a5c 17 #include "Dir.h"
thedo 166:3a9487d57a5c 18 #include "mbed.h"
thedo 166:3a9487d57a5c 19 #include <errno.h>
thedo 166:3a9487d57a5c 20
thedo 166:3a9487d57a5c 21
thedo 166:3a9487d57a5c 22 Dir::Dir()
thedo 166:3a9487d57a5c 23 : _fs(0), _dir(0)
thedo 166:3a9487d57a5c 24 {
thedo 166:3a9487d57a5c 25 }
thedo 166:3a9487d57a5c 26
thedo 166:3a9487d57a5c 27 Dir::Dir(FileSystem *fs, const char *path)
thedo 166:3a9487d57a5c 28 : _fs(0), _dir(0)
thedo 166:3a9487d57a5c 29 {
thedo 166:3a9487d57a5c 30 open(fs, path);
thedo 166:3a9487d57a5c 31 }
thedo 166:3a9487d57a5c 32
thedo 166:3a9487d57a5c 33 Dir::~Dir()
thedo 166:3a9487d57a5c 34 {
thedo 166:3a9487d57a5c 35 if (_fs) {
thedo 166:3a9487d57a5c 36 close();
thedo 166:3a9487d57a5c 37 }
thedo 166:3a9487d57a5c 38 }
thedo 166:3a9487d57a5c 39
thedo 166:3a9487d57a5c 40 int Dir::open(FileSystem *fs, const char *path)
thedo 166:3a9487d57a5c 41 {
thedo 166:3a9487d57a5c 42 if (_fs) {
thedo 166:3a9487d57a5c 43 return -EINVAL;
thedo 166:3a9487d57a5c 44 }
thedo 166:3a9487d57a5c 45
thedo 166:3a9487d57a5c 46 _fs = fs;
thedo 166:3a9487d57a5c 47 return _fs->dir_open(&_dir, path);
thedo 166:3a9487d57a5c 48 }
thedo 166:3a9487d57a5c 49
thedo 166:3a9487d57a5c 50 int Dir::close()
thedo 166:3a9487d57a5c 51 {
thedo 166:3a9487d57a5c 52 if (!_fs) {
thedo 166:3a9487d57a5c 53 return -EINVAL;
thedo 166:3a9487d57a5c 54 }
thedo 166:3a9487d57a5c 55
thedo 166:3a9487d57a5c 56 int err = _fs->dir_close(_dir);
thedo 166:3a9487d57a5c 57 _fs = 0;
thedo 166:3a9487d57a5c 58 return err;
thedo 166:3a9487d57a5c 59 }
thedo 166:3a9487d57a5c 60
thedo 166:3a9487d57a5c 61 ssize_t Dir::read(struct dirent *ent)
thedo 166:3a9487d57a5c 62 {
thedo 166:3a9487d57a5c 63 MBED_ASSERT(_fs);
thedo 166:3a9487d57a5c 64 memset(ent, 0, sizeof(struct dirent));
thedo 166:3a9487d57a5c 65 return _fs->dir_read(_dir, ent);
thedo 166:3a9487d57a5c 66 }
thedo 166:3a9487d57a5c 67
thedo 166:3a9487d57a5c 68 void Dir::seek(off_t offset)
thedo 166:3a9487d57a5c 69 {
thedo 166:3a9487d57a5c 70 MBED_ASSERT(_fs);
thedo 166:3a9487d57a5c 71 return _fs->dir_seek(_dir, offset);
thedo 166:3a9487d57a5c 72 }
thedo 166:3a9487d57a5c 73
thedo 166:3a9487d57a5c 74 off_t Dir::tell()
thedo 166:3a9487d57a5c 75 {
thedo 166:3a9487d57a5c 76 MBED_ASSERT(_fs);
thedo 166:3a9487d57a5c 77 return _fs->dir_tell(_dir);
thedo 166:3a9487d57a5c 78 }
thedo 166:3a9487d57a5c 79
thedo 166:3a9487d57a5c 80 void Dir::rewind()
thedo 166:3a9487d57a5c 81 {
thedo 166:3a9487d57a5c 82 MBED_ASSERT(_fs);
thedo 166:3a9487d57a5c 83 return _fs->dir_rewind(_dir);
thedo 166:3a9487d57a5c 84 }
thedo 166:3a9487d57a5c 85
thedo 166:3a9487d57a5c 86 size_t Dir::size()
thedo 166:3a9487d57a5c 87 {
thedo 166:3a9487d57a5c 88 MBED_ASSERT(_fs);
thedo 166:3a9487d57a5c 89 return _fs->dir_size(_dir);
thedo 166:3a9487d57a5c 90 }
thedo 166:3a9487d57a5c 91