Biomimetics MBED Library w/ Added Support for CAN3
Dependents: CAN_TEST SPIne_Plus_DYNO_SENSORS SPIne_Plus_v2 SPIne_Plus_Dyno_v2
platform/FilePath.cpp@3:993b4d6ff61e, 2021-03-09 (annotated)
- Committer:
- adimmit
- Date:
- Tue Mar 09 20:33:24 2021 +0000
- Revision:
- 3:993b4d6ff61e
- Parent:
- 0:083111ae2a11
added CAN3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
saloutos | 0:083111ae2a11 | 1 | /* mbed Microcontroller Library |
saloutos | 0:083111ae2a11 | 2 | * Copyright (c) 2006-2013 ARM Limited |
saloutos | 0:083111ae2a11 | 3 | * |
saloutos | 0:083111ae2a11 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
saloutos | 0:083111ae2a11 | 5 | * you may not use this file except in compliance with the License. |
saloutos | 0:083111ae2a11 | 6 | * You may obtain a copy of the License at |
saloutos | 0:083111ae2a11 | 7 | * |
saloutos | 0:083111ae2a11 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
saloutos | 0:083111ae2a11 | 9 | * |
saloutos | 0:083111ae2a11 | 10 | * Unless required by applicable law or agreed to in writing, software |
saloutos | 0:083111ae2a11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
saloutos | 0:083111ae2a11 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
saloutos | 0:083111ae2a11 | 13 | * See the License for the specific language governing permissions and |
saloutos | 0:083111ae2a11 | 14 | * limitations under the License. |
saloutos | 0:083111ae2a11 | 15 | */ |
saloutos | 0:083111ae2a11 | 16 | #include "platform/FilePath.h" |
saloutos | 0:083111ae2a11 | 17 | |
saloutos | 0:083111ae2a11 | 18 | namespace mbed { |
saloutos | 0:083111ae2a11 | 19 | |
saloutos | 0:083111ae2a11 | 20 | FilePath::FilePath(const char* file_path) : file_name(NULL), fb(NULL) { |
saloutos | 0:083111ae2a11 | 21 | if ((file_path[0] != '/') || (file_path[1] == 0)) return; |
saloutos | 0:083111ae2a11 | 22 | |
saloutos | 0:083111ae2a11 | 23 | const char* file_system = &file_path[1]; |
saloutos | 0:083111ae2a11 | 24 | file_name = file_system; |
saloutos | 0:083111ae2a11 | 25 | int len = 0; |
saloutos | 0:083111ae2a11 | 26 | while (true) { |
saloutos | 0:083111ae2a11 | 27 | char c = *file_name; |
saloutos | 0:083111ae2a11 | 28 | if (c == '/') { // end of object name |
saloutos | 0:083111ae2a11 | 29 | file_name++; // point to one char after the '/' |
saloutos | 0:083111ae2a11 | 30 | break; |
saloutos | 0:083111ae2a11 | 31 | } |
saloutos | 0:083111ae2a11 | 32 | if (c == 0) { // end of object name, with no filename |
saloutos | 0:083111ae2a11 | 33 | break; |
saloutos | 0:083111ae2a11 | 34 | } |
saloutos | 0:083111ae2a11 | 35 | len++; |
saloutos | 0:083111ae2a11 | 36 | file_name++; |
saloutos | 0:083111ae2a11 | 37 | } |
saloutos | 0:083111ae2a11 | 38 | |
saloutos | 0:083111ae2a11 | 39 | fb = FileBase::lookup(file_system, len); |
saloutos | 0:083111ae2a11 | 40 | } |
saloutos | 0:083111ae2a11 | 41 | |
saloutos | 0:083111ae2a11 | 42 | const char* FilePath::fileName(void) { |
saloutos | 0:083111ae2a11 | 43 | return file_name; |
saloutos | 0:083111ae2a11 | 44 | } |
saloutos | 0:083111ae2a11 | 45 | |
saloutos | 0:083111ae2a11 | 46 | bool FilePath::isFileSystem(void) { |
saloutos | 0:083111ae2a11 | 47 | if (NULL == fb) |
saloutos | 0:083111ae2a11 | 48 | return false; |
saloutos | 0:083111ae2a11 | 49 | return (fb->getPathType() == FileSystemPathType); |
saloutos | 0:083111ae2a11 | 50 | } |
saloutos | 0:083111ae2a11 | 51 | |
saloutos | 0:083111ae2a11 | 52 | FileSystemLike* FilePath::fileSystem(void) { |
saloutos | 0:083111ae2a11 | 53 | if (isFileSystem()) { |
saloutos | 0:083111ae2a11 | 54 | return static_cast<FileSystemLike*>(fb); |
saloutos | 0:083111ae2a11 | 55 | } |
saloutos | 0:083111ae2a11 | 56 | return NULL; |
saloutos | 0:083111ae2a11 | 57 | } |
saloutos | 0:083111ae2a11 | 58 | |
saloutos | 0:083111ae2a11 | 59 | bool FilePath::isFile(void) { |
saloutos | 0:083111ae2a11 | 60 | if (NULL == fb) |
saloutos | 0:083111ae2a11 | 61 | return false; |
saloutos | 0:083111ae2a11 | 62 | return (fb->getPathType() == FilePathType); |
saloutos | 0:083111ae2a11 | 63 | } |
saloutos | 0:083111ae2a11 | 64 | |
saloutos | 0:083111ae2a11 | 65 | FileLike* FilePath::file(void) { |
saloutos | 0:083111ae2a11 | 66 | if (isFile()) { |
saloutos | 0:083111ae2a11 | 67 | return (FileLike*)fb; |
saloutos | 0:083111ae2a11 | 68 | } |
saloutos | 0:083111ae2a11 | 69 | return NULL; |
saloutos | 0:083111ae2a11 | 70 | } |
saloutos | 0:083111ae2a11 | 71 | |
saloutos | 0:083111ae2a11 | 72 | bool FilePath::exists(void) { |
saloutos | 0:083111ae2a11 | 73 | return fb != NULL; |
saloutos | 0:083111ae2a11 | 74 | } |
saloutos | 0:083111ae2a11 | 75 | |
saloutos | 0:083111ae2a11 | 76 | } // namespace mbed |