Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
FilePath.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "drivers/FilePath.h" 00017 00018 namespace mbed { 00019 00020 FilePath::FilePath(const char* file_path) : file_name(NULL), fb(NULL) { 00021 if ((file_path[0] != '/') || (file_path[1] == 0)) return; 00022 00023 const char* file_system = &file_path[1]; 00024 file_name = file_system; 00025 int len = 0; 00026 while (true) { 00027 char c = *file_name; 00028 if (c == '/') { // end of object name 00029 file_name++; // point to one char after the '/' 00030 break; 00031 } 00032 if (c == 0) { // end of object name, with no filename 00033 break; 00034 } 00035 len++; 00036 file_name++; 00037 } 00038 00039 fb = FileBase::lookup(file_system, len); 00040 } 00041 00042 const char* FilePath::fileName(void) { 00043 return file_name; 00044 } 00045 00046 bool FilePath::isFileSystem(void) { 00047 if (NULL == fb) 00048 return false; 00049 return (fb->getPathType() == FileSystemPathType); 00050 } 00051 00052 FileSystemLike* FilePath::fileSystem(void) { 00053 if (isFileSystem()) { 00054 return (FileSystemLike*)fb; 00055 } 00056 return NULL; 00057 } 00058 00059 bool FilePath::isFile(void) { 00060 if (NULL == fb) 00061 return false; 00062 return (fb->getPathType() == FilePathType); 00063 } 00064 00065 FileLike* FilePath::file(void) { 00066 if (isFile()) { 00067 return (FileLike*)fb; 00068 } 00069 return NULL; 00070 } 00071 00072 bool FilePath::exists(void) { 00073 return fb != NULL; 00074 } 00075 00076 } // namespace mbed
Generated on Tue Jul 12 2022 10:59:56 by
