Modified mbed library sources only for STM32F030K6, LQFP32 (0.8mm pitch) package, 32K Flash, 4K SRAM. Compiler target: Nucleo 32F030R8
Fork of mbed-src by
common/FileBase.cpp@13:0645d8841f51, 2013-08-05 (annotated)
- Committer:
- bogdanm
- Date:
- Mon Aug 05 14:12:34 2013 +0300
- Revision:
- 13:0645d8841f51
- Parent:
- 10:3bc89ef62ce7
- Child:
- 212:34d62c0b2af6
Update mbed sources to revision 64
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 13:0645d8841f51 | 1 | /* mbed Microcontroller Library |
bogdanm | 13:0645d8841f51 | 2 | * Copyright (c) 2006-2013 ARM Limited |
bogdanm | 13:0645d8841f51 | 3 | * |
bogdanm | 13:0645d8841f51 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
bogdanm | 13:0645d8841f51 | 5 | * you may not use this file except in compliance with the License. |
bogdanm | 13:0645d8841f51 | 6 | * You may obtain a copy of the License at |
bogdanm | 13:0645d8841f51 | 7 | * |
bogdanm | 13:0645d8841f51 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
bogdanm | 13:0645d8841f51 | 9 | * |
bogdanm | 13:0645d8841f51 | 10 | * Unless required by applicable law or agreed to in writing, software |
bogdanm | 13:0645d8841f51 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
bogdanm | 13:0645d8841f51 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
bogdanm | 13:0645d8841f51 | 13 | * See the License for the specific language governing permissions and |
bogdanm | 13:0645d8841f51 | 14 | * limitations under the License. |
bogdanm | 13:0645d8841f51 | 15 | */ |
bogdanm | 13:0645d8841f51 | 16 | #include "FileBase.h" |
bogdanm | 13:0645d8841f51 | 17 | |
bogdanm | 13:0645d8841f51 | 18 | namespace mbed { |
bogdanm | 13:0645d8841f51 | 19 | |
bogdanm | 13:0645d8841f51 | 20 | FileBase *FileBase::_head = NULL; |
bogdanm | 13:0645d8841f51 | 21 | |
bogdanm | 13:0645d8841f51 | 22 | FileBase::FileBase(const char *name, PathType t) { |
bogdanm | 13:0645d8841f51 | 23 | _name = name; |
bogdanm | 13:0645d8841f51 | 24 | _path_type = t; |
bogdanm | 13:0645d8841f51 | 25 | |
bogdanm | 13:0645d8841f51 | 26 | if (name != NULL) { |
bogdanm | 13:0645d8841f51 | 27 | // put this object at head of the list |
bogdanm | 13:0645d8841f51 | 28 | _next = _head; |
bogdanm | 13:0645d8841f51 | 29 | _head = this; |
bogdanm | 13:0645d8841f51 | 30 | } else { |
bogdanm | 13:0645d8841f51 | 31 | _next = NULL; |
bogdanm | 13:0645d8841f51 | 32 | } |
bogdanm | 13:0645d8841f51 | 33 | } |
bogdanm | 13:0645d8841f51 | 34 | |
bogdanm | 13:0645d8841f51 | 35 | FileBase::~FileBase() { |
bogdanm | 13:0645d8841f51 | 36 | if (_name != NULL) { |
bogdanm | 13:0645d8841f51 | 37 | // remove this object from the list |
bogdanm | 13:0645d8841f51 | 38 | if (_head == this) { // first in the list, so just drop me |
bogdanm | 13:0645d8841f51 | 39 | _head = _next; |
bogdanm | 13:0645d8841f51 | 40 | } else { // find the object before me, then drop me |
bogdanm | 13:0645d8841f51 | 41 | FileBase *p = _head; |
bogdanm | 13:0645d8841f51 | 42 | while (p->_next != this) { |
bogdanm | 13:0645d8841f51 | 43 | p = p->_next; |
bogdanm | 13:0645d8841f51 | 44 | } |
bogdanm | 13:0645d8841f51 | 45 | p->_next = _next; |
bogdanm | 13:0645d8841f51 | 46 | } |
bogdanm | 13:0645d8841f51 | 47 | } |
bogdanm | 13:0645d8841f51 | 48 | } |
bogdanm | 13:0645d8841f51 | 49 | |
bogdanm | 13:0645d8841f51 | 50 | FileBase *FileBase::lookup(const char *name, unsigned int len) { |
bogdanm | 13:0645d8841f51 | 51 | FileBase *p = _head; |
bogdanm | 13:0645d8841f51 | 52 | while (p != NULL) { |
bogdanm | 13:0645d8841f51 | 53 | /* Check that p->_name matches name and is the correct length */ |
bogdanm | 13:0645d8841f51 | 54 | if (p->_name != NULL && std::strncmp(p->_name, name, len) == 0 && std::strlen(p->_name) == len) { |
bogdanm | 13:0645d8841f51 | 55 | return p; |
bogdanm | 13:0645d8841f51 | 56 | } |
bogdanm | 13:0645d8841f51 | 57 | p = p->_next; |
bogdanm | 13:0645d8841f51 | 58 | } |
bogdanm | 13:0645d8841f51 | 59 | return NULL; |
bogdanm | 13:0645d8841f51 | 60 | } |
bogdanm | 13:0645d8841f51 | 61 | |
bogdanm | 13:0645d8841f51 | 62 | FileBase *FileBase::get(int n) { |
bogdanm | 13:0645d8841f51 | 63 | FileBase *p = _head; |
bogdanm | 13:0645d8841f51 | 64 | int m = 0; |
bogdanm | 13:0645d8841f51 | 65 | while (p != NULL) { |
bogdanm | 13:0645d8841f51 | 66 | if (m == n) return p; |
bogdanm | 13:0645d8841f51 | 67 | |
bogdanm | 13:0645d8841f51 | 68 | m++; |
bogdanm | 13:0645d8841f51 | 69 | p = p->_next; |
bogdanm | 13:0645d8841f51 | 70 | } |
bogdanm | 13:0645d8841f51 | 71 | return NULL; |
bogdanm | 13:0645d8841f51 | 72 | } |
bogdanm | 13:0645d8841f51 | 73 | |
bogdanm | 13:0645d8841f51 | 74 | const char* FileBase::getName(void) { |
bogdanm | 13:0645d8841f51 | 75 | return _name; |
bogdanm | 13:0645d8841f51 | 76 | } |
bogdanm | 13:0645d8841f51 | 77 | |
bogdanm | 13:0645d8841f51 | 78 | PathType FileBase::getPathType(void) { |
bogdanm | 13:0645d8841f51 | 79 | return _path_type; |
bogdanm | 13:0645d8841f51 | 80 | } |
bogdanm | 13:0645d8841f51 | 81 | |
bogdanm | 13:0645d8841f51 | 82 | } // namespace mbed |
bogdanm | 13:0645d8841f51 | 83 |