Modified for BG96
Fork of mbed-dev by
Diff: platform/FileBase.cpp
- Revision:
- 187:0387e8f68319
- Parent:
- 167:e84263d55307
--- a/platform/FileBase.cpp Fri Jun 22 16:45:37 2018 +0100 +++ b/platform/FileBase.cpp Thu Sep 06 13:40:20 2018 +0100 @@ -23,8 +23,9 @@ SingletonPtr<PlatformMutex> FileBase::_mutex; FileBase::FileBase(const char *name, PathType t) : _next(NULL), - _name(name), - _path_type(t) { + _name(name), + _path_type(t) +{ _mutex->lock(); if (name != NULL) { // put this object at head of the list @@ -36,7 +37,8 @@ _mutex->unlock(); } -FileBase::~FileBase() { +FileBase::~FileBase() +{ _mutex->lock(); if (_name != NULL) { // remove this object from the list @@ -53,12 +55,13 @@ _mutex->unlock(); if (getPathType() == FilePathType) { - extern void remove_filehandle(FileHandle *file); - remove_filehandle(static_cast<FileHandle*>(static_cast<FileLike*>(this))); + extern void remove_filehandle(FileHandle * file); + remove_filehandle(static_cast<FileHandle *>(static_cast<FileLike *>(this))); } } -FileBase *FileBase::lookup(const char *name, unsigned int len) { +FileBase *FileBase::lookup(const char *name, unsigned int len) +{ _mutex->lock(); FileBase *p = _head; while (p != NULL) { @@ -73,7 +76,8 @@ return NULL; } -FileBase *FileBase::get(int n) { +FileBase *FileBase::get(int n) +{ _mutex->lock(); FileBase *p = _head; int m = 0; @@ -90,12 +94,14 @@ return NULL; } -const char* FileBase::getName(void) { +const char *FileBase::getName(void) +{ // Constant read so no lock needed return _name; } -PathType FileBase::getPathType(void) { +PathType FileBase::getPathType(void) +{ // Constant read so no lock needed return _path_type; }