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.
Dependencies: nRF51_Vdd TextLCD BME280
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 "platform/FilePath.h" 00017 00018 namespace mbed { 00019 00020 FilePath::FilePath(const char *file_path) : file_name(NULL), fb(NULL) 00021 { 00022 // skip slashes 00023 file_path += strspn(file_path, "/"); 00024 00025 const char *file_system = file_path; 00026 file_name = file_system; 00027 int len = 0; 00028 while (true) { 00029 char c = *file_name; 00030 if (c == '/') { // end of object name 00031 file_name++; // point to one char after the '/' 00032 break; 00033 } 00034 if (c == 0) { // end of object name, with no filename 00035 break; 00036 } 00037 len++; 00038 file_name++; 00039 } 00040 00041 MBED_ASSERT(len != 0); 00042 fb = FileBase::lookup(file_system, len); 00043 } 00044 00045 const char *FilePath::fileName(void) 00046 { 00047 return file_name; 00048 } 00049 00050 bool FilePath::isFileSystem(void) 00051 { 00052 if (NULL == fb) { 00053 return false; 00054 } 00055 return (fb->getPathType() == FileSystemPathType); 00056 } 00057 00058 FileSystemLike *FilePath::fileSystem(void) 00059 { 00060 if (isFileSystem()) { 00061 return static_cast<FileSystemLike *>(fb); 00062 } 00063 return NULL; 00064 } 00065 00066 bool FilePath::isFile(void) 00067 { 00068 if (NULL == fb) { 00069 return false; 00070 } 00071 return (fb->getPathType() == FilePathType); 00072 } 00073 00074 FileLike *FilePath::file(void) 00075 { 00076 if (isFile()) { 00077 return (FileLike *)fb; 00078 } 00079 return NULL; 00080 } 00081 00082 bool FilePath::exists(void) 00083 { 00084 return fb != NULL; 00085 } 00086 00087 } // namespace mbed
Generated on Tue Jul 12 2022 15:15:45 by
