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.
FATFileHandle.cpp
00001 /* mbed Microcontroller Library - FATFileHandle 00002 Copyright (c) 2008, sford */ 00003 00004 //Modified by Thomas Hamilton, Copyright 2010 00005 00006 #include "FATFileHandle.h" 00007 00008 FATFileHandle::FATFileHandle(FAT_FIL InputFilStr) 00009 { 00010 FileObject = InputFilStr; 00011 } 00012 00013 ssize_t FATFileHandle::write(const void* buffer, size_t length) 00014 { 00015 UINT ByteWritten; 00016 if (f_write(&FileObject, buffer, (UINT)length, &ByteWritten)) 00017 { 00018 return -1; 00019 } 00020 else 00021 { 00022 return (ssize_t)ByteWritten; 00023 } 00024 } 00025 00026 int FATFileHandle::close() 00027 { 00028 if (f_close(&FileObject)) 00029 { 00030 return -1; 00031 } 00032 else 00033 { 00034 delete this; 00035 return 0; 00036 } 00037 } 00038 00039 ssize_t FATFileHandle::read(void* buffer, size_t length) 00040 { 00041 UINT ByteRead; 00042 if (f_read(&FileObject, buffer, (UINT)length, &ByteRead)) 00043 { 00044 return -1; 00045 } 00046 else 00047 { 00048 return (ssize_t)ByteRead; 00049 } 00050 } 00051 00052 int FATFileHandle::isatty() 00053 { 00054 return 0; 00055 } 00056 00057 off_t FATFileHandle::lseek(off_t offset, int whence) 00058 { 00059 switch (whence) 00060 { 00061 case SEEK_CUR: offset += FileObject.fptr; break; 00062 case SEEK_END: offset += FileObject.fsize; break; 00063 } 00064 if (f_lseek(&FileObject, (DWORD)offset)) 00065 { 00066 return -1; 00067 } 00068 else 00069 { 00070 return (off_t)FileObject.fptr; 00071 } 00072 } 00073 00074 int FATFileHandle::fsync() 00075 { 00076 if (f_sync(&FileObject)) 00077 { 00078 return -1; 00079 } 00080 else 00081 { 00082 return 0; 00083 } 00084 } 00085 00086 off_t FATFileHandle::flen() 00087 { 00088 return (off_t)FileObject.fsize; 00089 }
Generated on Wed Jul 13 2022 08:04:37 by
1.7.2