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.
Dependents: SDFileSystem IPS SDFileSystem SDFileSystem ... more
Fork of FATFileSystem by
FATFileHandle.h@8:c4baca9a2c3d, 2016-08-25 (annotated)
- Committer:
 - Kojto
 - Date:
 - Thu Aug 25 09:34:29 2016 +0100
 - Revision:
 - 8:c4baca9a2c3d
 - Parent:
 - 1:46ce1e16c870
 
Synchronized with git revision 4047ff95767d307
- fix _name error (getName())
- add thread safety
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| emilmont | 1:46ce1e16c870 | 1 | /* mbed Microcontroller Library | 
| emilmont | 1:46ce1e16c870 | 2 | * Copyright (c) 2006-2012 ARM Limited | 
| emilmont | 1:46ce1e16c870 | 3 | * | 
| emilmont | 1:46ce1e16c870 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | 
| emilmont | 1:46ce1e16c870 | 5 | * of this software and associated documentation files (the "Software"), to deal | 
| emilmont | 1:46ce1e16c870 | 6 | * in the Software without restriction, including without limitation the rights | 
| emilmont | 1:46ce1e16c870 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
| emilmont | 1:46ce1e16c870 | 8 | * copies of the Software, and to permit persons to whom the Software is | 
| emilmont | 1:46ce1e16c870 | 9 | * furnished to do so, subject to the following conditions: | 
| emilmont | 1:46ce1e16c870 | 10 | * | 
| emilmont | 1:46ce1e16c870 | 11 | * The above copyright notice and this permission notice shall be included in | 
| emilmont | 1:46ce1e16c870 | 12 | * all copies or substantial portions of the Software. | 
| emilmont | 1:46ce1e16c870 | 13 | * | 
| emilmont | 1:46ce1e16c870 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
| emilmont | 1:46ce1e16c870 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
| emilmont | 1:46ce1e16c870 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
| emilmont | 1:46ce1e16c870 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
| emilmont | 1:46ce1e16c870 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
| emilmont | 1:46ce1e16c870 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 
| emilmont | 1:46ce1e16c870 | 20 | * SOFTWARE. | 
| emilmont | 1:46ce1e16c870 | 21 | */ | 
| emilmont | 1:46ce1e16c870 | 22 | #ifndef MBED_FATFILEHANDLE_H | 
| emilmont | 1:46ce1e16c870 | 23 | #define MBED_FATFILEHANDLE_H | 
| emilmont | 1:46ce1e16c870 | 24 | |
| emilmont | 1:46ce1e16c870 | 25 | #include "FileHandle.h" | 
| Kojto | 8:c4baca9a2c3d | 26 | #include "PlatformMutex.h" | 
| emilmont | 1:46ce1e16c870 | 27 | |
| emilmont | 1:46ce1e16c870 | 28 | using namespace mbed; | 
| emilmont | 1:46ce1e16c870 | 29 | |
| emilmont | 1:46ce1e16c870 | 30 | class FATFileHandle : public FileHandle { | 
| emilmont | 1:46ce1e16c870 | 31 | public: | 
| emilmont | 1:46ce1e16c870 | 32 | |
| Kojto | 8:c4baca9a2c3d | 33 | FATFileHandle(FIL fh, PlatformMutex * mutex); | 
| emilmont | 1:46ce1e16c870 | 34 | virtual int close(); | 
| emilmont | 1:46ce1e16c870 | 35 | virtual ssize_t write(const void* buffer, size_t length); | 
| emilmont | 1:46ce1e16c870 | 36 | virtual ssize_t read(void* buffer, size_t length); | 
| emilmont | 1:46ce1e16c870 | 37 | virtual int isatty(); | 
| emilmont | 1:46ce1e16c870 | 38 | virtual off_t lseek(off_t position, int whence); | 
| emilmont | 1:46ce1e16c870 | 39 | virtual int fsync(); | 
| emilmont | 1:46ce1e16c870 | 40 | virtual off_t flen(); | 
| emilmont | 1:46ce1e16c870 | 41 | |
| emilmont | 1:46ce1e16c870 | 42 | protected: | 
| emilmont | 1:46ce1e16c870 | 43 | |
| Kojto | 8:c4baca9a2c3d | 44 | virtual void lock(); | 
| Kojto | 8:c4baca9a2c3d | 45 | virtual void unlock(); | 
| Kojto | 8:c4baca9a2c3d | 46 | |
| emilmont | 1:46ce1e16c870 | 47 | FIL _fh; | 
| Kojto | 8:c4baca9a2c3d | 48 | PlatformMutex * _mutex; | 
| emilmont | 1:46ce1e16c870 | 49 | |
| emilmont | 1:46ce1e16c870 | 50 | }; | 
| emilmont | 1:46ce1e16c870 | 51 | |
| emilmont | 1:46ce1e16c870 | 52 | #endif | 

