Opencv 3.1 project on GR-PEACH board
Fork of gr-peach-opencv-project by
platform/FileHandle.cpp@166:3a9487d57a5c, 2017-06-29 (annotated)
- Committer:
- thedo
- Date:
- Thu Jun 29 11:00:41 2017 +0000
- Revision:
- 166:3a9487d57a5c
This is Opencv 3.1 project on GR-PEACH board
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 166:3a9487d57a5c | 1 | /* mbed Microcontroller Library |
thedo | 166:3a9487d57a5c | 2 | * Copyright (c) 2006-2016 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 | #include "FileHandle.h" |
thedo | 166:3a9487d57a5c | 17 | #include "platform/mbed_retarget.h" |
thedo | 166:3a9487d57a5c | 18 | #include "platform/mbed_critical.h" |
thedo | 166:3a9487d57a5c | 19 | |
thedo | 166:3a9487d57a5c | 20 | namespace mbed { |
thedo | 166:3a9487d57a5c | 21 | |
thedo | 166:3a9487d57a5c | 22 | off_t FileHandle::size() |
thedo | 166:3a9487d57a5c | 23 | { |
thedo | 166:3a9487d57a5c | 24 | /* remember our current position */ |
thedo | 166:3a9487d57a5c | 25 | off_t off = seek(0, SEEK_CUR); |
thedo | 166:3a9487d57a5c | 26 | if (off < 0) { |
thedo | 166:3a9487d57a5c | 27 | return off; |
thedo | 166:3a9487d57a5c | 28 | } |
thedo | 166:3a9487d57a5c | 29 | /* seek to the end to get the file length */ |
thedo | 166:3a9487d57a5c | 30 | off_t size = seek(0, SEEK_END); |
thedo | 166:3a9487d57a5c | 31 | /* return to our old position */ |
thedo | 166:3a9487d57a5c | 32 | seek(off, SEEK_SET); |
thedo | 166:3a9487d57a5c | 33 | return size; |
thedo | 166:3a9487d57a5c | 34 | } |
thedo | 166:3a9487d57a5c | 35 | |
thedo | 166:3a9487d57a5c | 36 | std::FILE *fdopen(FileHandle *fh, const char *mode) |
thedo | 166:3a9487d57a5c | 37 | { |
thedo | 166:3a9487d57a5c | 38 | return mbed_fdopen(fh, mode); |
thedo | 166:3a9487d57a5c | 39 | } |
thedo | 166:3a9487d57a5c | 40 | |
thedo | 166:3a9487d57a5c | 41 | } // namespace mbed |
thedo | 166:3a9487d57a5c | 42 |