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