[11U68]fix P0_11 to use GPIO
Fork of mbed-src by
Embed:
(wiki syntax)
Show/hide line numbers
FileSystemLike.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 "FileSystemLike.h" 00017 00018 namespace mbed { 00019 00020 class BaseDirHandle : public DirHandle { 00021 public: 00022 /* 00023 We keep track of our current location as the n'th object in the 00024 FileSystemLike list. Using a Base* instead would cause problems if that 00025 object were to be destroyed between readdirs. 00026 Using this method does mean though that destroying/creating objects can 00027 give unusual results from readdir. 00028 */ 00029 off_t n; 00030 struct dirent cur_entry; 00031 00032 BaseDirHandle() : n(0), cur_entry() { 00033 } 00034 00035 virtual int closedir() { 00036 delete this; 00037 return 0; 00038 } 00039 00040 virtual struct dirent *readdir() { 00041 FileBase *ptr = FileBase::get(n); 00042 if (ptr == NULL) return NULL; 00043 00044 /* Increment n, so next readdir gets the next item */ 00045 n++; 00046 00047 /* Setup cur entry and return a pointer to it */ 00048 std::strncpy(cur_entry.d_name, ptr->getName(), NAME_MAX); 00049 return &cur_entry; 00050 } 00051 00052 virtual off_t telldir() { 00053 return n; 00054 } 00055 00056 virtual void seekdir(off_t offset) { 00057 n = offset; 00058 } 00059 00060 virtual void rewinddir() { 00061 n = 0; 00062 } 00063 }; 00064 00065 FileSystemLike::FileSystemLike(const char *name) : FileBase(name, FileSystemPathType) { 00066 00067 } 00068 00069 FileSystemLike::~FileSystemLike() { 00070 00071 } 00072 00073 DirHandle *FileSystemLike::opendir() { 00074 return new BaseDirHandle(); 00075 } 00076 00077 } // namespace mbed
Generated on Tue Jul 12 2022 21:24:12 by 1.7.2