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