mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
184:08ed48f1de7f
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 167:e84263d55307 1 /* mbed Microcontroller Library
AnnaBridge 167:e84263d55307 2 * Copyright (c) 2006-2016 ARM Limited
AnnaBridge 189:f392fc9709a3 3 * SPDX-License-Identifier: Apache-2.0
AnnaBridge 167:e84263d55307 4 *
AnnaBridge 167:e84263d55307 5 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 167:e84263d55307 6 * you may not use this file except in compliance with the License.
AnnaBridge 167:e84263d55307 7 * You may obtain a copy of the License at
AnnaBridge 167:e84263d55307 8 *
AnnaBridge 167:e84263d55307 9 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 167:e84263d55307 10 *
AnnaBridge 167:e84263d55307 11 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 167:e84263d55307 12 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 167:e84263d55307 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 167:e84263d55307 14 * See the License for the specific language governing permissions and
AnnaBridge 167:e84263d55307 15 * limitations under the License.
AnnaBridge 167:e84263d55307 16 */
AnnaBridge 167:e84263d55307 17 #include "FileHandle.h"
AnnaBridge 167:e84263d55307 18 #include "platform/mbed_retarget.h"
AnnaBridge 167:e84263d55307 19 #include "platform/mbed_critical.h"
AnnaBridge 167:e84263d55307 20
AnnaBridge 167:e84263d55307 21 namespace mbed {
AnnaBridge 167:e84263d55307 22
AnnaBridge 167:e84263d55307 23 off_t FileHandle::size()
AnnaBridge 167:e84263d55307 24 {
AnnaBridge 167:e84263d55307 25 /* remember our current position */
AnnaBridge 167:e84263d55307 26 off_t off = seek(0, SEEK_CUR);
AnnaBridge 167:e84263d55307 27 if (off < 0) {
AnnaBridge 167:e84263d55307 28 return off;
AnnaBridge 167:e84263d55307 29 }
AnnaBridge 167:e84263d55307 30 /* seek to the end to get the file length */
AnnaBridge 167:e84263d55307 31 off_t size = seek(0, SEEK_END);
AnnaBridge 167:e84263d55307 32 /* return to our old position */
AnnaBridge 167:e84263d55307 33 seek(off, SEEK_SET);
AnnaBridge 167:e84263d55307 34 return size;
AnnaBridge 167:e84263d55307 35 }
AnnaBridge 167:e84263d55307 36
AnnaBridge 167:e84263d55307 37 } // namespace mbed