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