mbed library sources, mbed-dev only for TYBLE16
Fork of mbed-dev by
Please refer flowing link.
/users/kenjiArai/notebook/tyble16-module-will-become-a-mbed-family--mbedliza/
platform/FileHandle.cpp@182:976b131d2800, 2018-02-25 (annotated)
- Committer:
- kenjiArai
- Date:
- Sun Feb 25 02:00:51 2018 +0000
- Revision:
- 182:976b131d2800
- Parent:
- 167:e84263d55307
Only for TYBLE16
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 167:e84263d55307 | 1 | /* mbed Microcontroller Library |
AnnaBridge | 167:e84263d55307 | 2 | * Copyright (c) 2006-2016 ARM Limited |
AnnaBridge | 167:e84263d55307 | 3 | * |
AnnaBridge | 167:e84263d55307 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
AnnaBridge | 167:e84263d55307 | 5 | * you may not use this file except in compliance with the License. |
AnnaBridge | 167:e84263d55307 | 6 | * You may obtain a copy of the License at |
AnnaBridge | 167:e84263d55307 | 7 | * |
AnnaBridge | 167:e84263d55307 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
AnnaBridge | 167:e84263d55307 | 9 | * |
AnnaBridge | 167:e84263d55307 | 10 | * Unless required by applicable law or agreed to in writing, software |
AnnaBridge | 167:e84263d55307 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AnnaBridge | 167:e84263d55307 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AnnaBridge | 167:e84263d55307 | 13 | * See the License for the specific language governing permissions and |
AnnaBridge | 167:e84263d55307 | 14 | * limitations under the License. |
AnnaBridge | 167:e84263d55307 | 15 | */ |
AnnaBridge | 167:e84263d55307 | 16 | #include "FileHandle.h" |
AnnaBridge | 167:e84263d55307 | 17 | #include "platform/mbed_retarget.h" |
AnnaBridge | 167:e84263d55307 | 18 | #include "platform/mbed_critical.h" |
AnnaBridge | 167:e84263d55307 | 19 | |
AnnaBridge | 167:e84263d55307 | 20 | namespace mbed { |
AnnaBridge | 167:e84263d55307 | 21 | |
AnnaBridge | 167:e84263d55307 | 22 | off_t FileHandle::size() |
AnnaBridge | 167:e84263d55307 | 23 | { |
AnnaBridge | 167:e84263d55307 | 24 | /* remember our current position */ |
AnnaBridge | 167:e84263d55307 | 25 | off_t off = seek(0, SEEK_CUR); |
AnnaBridge | 167:e84263d55307 | 26 | if (off < 0) { |
AnnaBridge | 167:e84263d55307 | 27 | return off; |
AnnaBridge | 167:e84263d55307 | 28 | } |
AnnaBridge | 167:e84263d55307 | 29 | /* seek to the end to get the file length */ |
AnnaBridge | 167:e84263d55307 | 30 | off_t size = seek(0, SEEK_END); |
AnnaBridge | 167:e84263d55307 | 31 | /* return to our old position */ |
AnnaBridge | 167:e84263d55307 | 32 | seek(off, SEEK_SET); |
AnnaBridge | 167:e84263d55307 | 33 | return size; |
AnnaBridge | 167:e84263d55307 | 34 | } |
AnnaBridge | 167:e84263d55307 | 35 | |
AnnaBridge | 167:e84263d55307 | 36 | std::FILE *fdopen(FileHandle *fh, const char *mode) |
AnnaBridge | 167:e84263d55307 | 37 | { |
AnnaBridge | 167:e84263d55307 | 38 | return mbed_fdopen(fh, mode); |
AnnaBridge | 167:e84263d55307 | 39 | } |
AnnaBridge | 167:e84263d55307 | 40 | |
AnnaBridge | 167:e84263d55307 | 41 | } // namespace mbed |