Nathan Yonkee
/
Nucleo_sinewave_output_copy
init
mbed-os/platform/FileHandle.cpp@10:46a4cf51ee38, 2018-03-02 (annotated)
- Committer:
- Nathan Yonkee
- Date:
- Fri Mar 02 07:16:49 2018 -0700
- Revision:
- 10:46a4cf51ee38
- Parent:
- 9:d58e77ebd769
remove mbed-os
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nathan Yonkee |
9:d58e77ebd769 | 1 | /* mbed Microcontroller Library |
Nathan Yonkee |
9:d58e77ebd769 | 2 | * Copyright (c) 2006-2016 ARM Limited |
Nathan Yonkee |
9:d58e77ebd769 | 3 | * |
Nathan Yonkee |
9:d58e77ebd769 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Nathan Yonkee |
9:d58e77ebd769 | 5 | * you may not use this file except in compliance with the License. |
Nathan Yonkee |
9:d58e77ebd769 | 6 | * You may obtain a copy of the License at |
Nathan Yonkee |
9:d58e77ebd769 | 7 | * |
Nathan Yonkee |
9:d58e77ebd769 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Nathan Yonkee |
9:d58e77ebd769 | 9 | * |
Nathan Yonkee |
9:d58e77ebd769 | 10 | * Unless required by applicable law or agreed to in writing, software |
Nathan Yonkee |
9:d58e77ebd769 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Nathan Yonkee |
9:d58e77ebd769 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Nathan Yonkee |
9:d58e77ebd769 | 13 | * See the License for the specific language governing permissions and |
Nathan Yonkee |
9:d58e77ebd769 | 14 | * limitations under the License. |
Nathan Yonkee |
9:d58e77ebd769 | 15 | */ |
Nathan Yonkee |
9:d58e77ebd769 | 16 | #include "FileHandle.h" |
Nathan Yonkee |
9:d58e77ebd769 | 17 | #include "platform/mbed_retarget.h" |
Nathan Yonkee |
9:d58e77ebd769 | 18 | #include "platform/mbed_critical.h" |
Nathan Yonkee |
9:d58e77ebd769 | 19 | |
Nathan Yonkee |
9:d58e77ebd769 | 20 | namespace mbed { |
Nathan Yonkee |
9:d58e77ebd769 | 21 | |
Nathan Yonkee |
9:d58e77ebd769 | 22 | off_t FileHandle::size() |
Nathan Yonkee |
9:d58e77ebd769 | 23 | { |
Nathan Yonkee |
9:d58e77ebd769 | 24 | /* remember our current position */ |
Nathan Yonkee |
9:d58e77ebd769 | 25 | off_t off = seek(0, SEEK_CUR); |
Nathan Yonkee |
9:d58e77ebd769 | 26 | if (off < 0) { |
Nathan Yonkee |
9:d58e77ebd769 | 27 | return off; |
Nathan Yonkee |
9:d58e77ebd769 | 28 | } |
Nathan Yonkee |
9:d58e77ebd769 | 29 | /* seek to the end to get the file length */ |
Nathan Yonkee |
9:d58e77ebd769 | 30 | off_t size = seek(0, SEEK_END); |
Nathan Yonkee |
9:d58e77ebd769 | 31 | /* return to our old position */ |
Nathan Yonkee |
9:d58e77ebd769 | 32 | seek(off, SEEK_SET); |
Nathan Yonkee |
9:d58e77ebd769 | 33 | return size; |
Nathan Yonkee |
9:d58e77ebd769 | 34 | } |
Nathan Yonkee |
9:d58e77ebd769 | 35 | |
Nathan Yonkee |
9:d58e77ebd769 | 36 | } // namespace mbed |