Semihosted file handles for targets without DEVICE_SEMIHOST or DEVICE_LOCALFILESYSTEM
Embed:
(wiki syntax)
Show/hide line numbers
SemihostedFileSystem.h
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 #ifndef SEMIHOSTEDFILESYSTEM_H 00017 #define SEMIHOSTEDFILESYSTEM_H 00018 00019 #include "platform/platform.h" 00020 00021 #include "platform/FileSystemLike.h" 00022 #include "platform/PlatformMutex.h" 00023 #include "platform/NonCopyable.h" 00024 00025 /** \addtogroup platform */ 00026 /** @{*/ 00027 00028 FILEHANDLE semihosted_file_open(const char* name, int flags); 00029 /** @}*/ 00030 00031 /** 00032 * @class SemihostedFileHandle 00033 * @ingroup platform 00034 */ 00035 class SemihostedFileHandle : public mbed::FileHandle, private mbed::NonCopyable<SemihostedFileHandle> { 00036 00037 public: 00038 SemihostedFileHandle(FILEHANDLE fh); 00039 SemihostedFileHandle(const char* name, int flags); 00040 00041 virtual int close(); 00042 00043 virtual ssize_t write(const void *buffer, size_t length); 00044 00045 virtual ssize_t read(void *buffer, size_t length); 00046 00047 virtual int isatty(); 00048 00049 virtual off_t seek(off_t position, int whence); 00050 00051 virtual int sync(); 00052 00053 virtual off_t size(); 00054 00055 int printf(const char *format, ...); 00056 00057 protected: 00058 virtual void lock(); 00059 virtual void unlock(); 00060 FILEHANDLE _fh; 00061 int pos; 00062 PlatformMutex _mutex; 00063 }; 00064 00065 #endif
Generated on Thu Jul 14 2022 18:48:16 by
1.7.2