Skip to content

Commit 76987ca

Browse files
committed
Rename internal lock/unlock APIs
1 parent 2451ae0 commit 76987ca

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class Adafruit_LittleFS
7878
lfs_t _lfs;
7979

8080
// these two functions need access to the private _mutex variable:
81-
friend void Adafruit_LittleFS_Namespace::File::DoNotCallFromOutsideClass_LockFilesystem(void);
82-
friend void Adafruit_LittleFS_Namespace::File::DoNotCallFromOutsideClass_UnlockFilesystem(void);
81+
friend void Adafruit_LittleFS_Namespace::File::_LockFilesystem(void);
82+
friend void Adafruit_LittleFS_Namespace::File::_UnlockFilesystem(void);
8383
//static_assert(configSUPPORT_STATIC_ALLOCATION == 1, "Currently only supports configuration with STATIC_ALLOCATION enabled");
8484
SemaphoreHandle_t _mutex;
8585

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ bool File::_open_dir (char const *filepath)
103103
bool File::open (char const *filepath, uint8_t mode)
104104
{
105105
bool ret = false;
106-
this->DoNotCallFromOutsideClass_LockFilesystem();
106+
this->_LockFilesystem();
107107
ret = this->_open(filepath, mode);
108-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
108+
this->_UnlockFilesystem();
109109
return ret;
110110
}
111111
bool File::_open (char const *filepath, uint8_t mode)
@@ -150,7 +150,7 @@ size_t File::write (uint8_t ch)
150150
size_t File::write (uint8_t const *buf, size_t size)
151151
{
152152
lfs_ssize_t wrcount = 0;
153-
this->DoNotCallFromOutsideClass_LockFilesystem();
153+
this->_LockFilesystem();
154154
if (!this->_is_dir)
155155
{
156156
wrcount = lfs_file_write(_fs->getFS(), _file, buf, size);
@@ -159,7 +159,7 @@ size_t File::write (uint8_t const *buf, size_t size)
159159
wrcount = 0;
160160
};
161161
}
162-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
162+
this->_UnlockFilesystem();
163163
return wrcount;
164164
}
165165

@@ -178,19 +178,19 @@ int File::read (void)
178178
int File::read (void *buf, uint16_t nbyte)
179179
{
180180
int ret = 0;
181-
this->DoNotCallFromOutsideClass_LockFilesystem();
181+
this->_LockFilesystem();
182182
if (!this->_is_dir)
183183
{
184184
ret = lfs_file_read(_fs->getFS(), _file, buf, nbyte);
185185
}
186-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
186+
this->_UnlockFilesystem();
187187
return ret;
188188
}
189189

190190
int File::peek (void)
191191
{
192192
int ret = -1;
193-
this->DoNotCallFromOutsideClass_LockFilesystem();
193+
this->_LockFilesystem();
194194
if (!this->_is_dir)
195195
{
196196
uint32_t pos = lfs_file_tell(_fs->getFS(), _file);
@@ -201,77 +201,77 @@ int File::peek (void)
201201
}
202202
(void)lfs_file_seek(_fs->getFS(), _file, pos, LFS_SEEK_SET);
203203
}
204-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
204+
this->_UnlockFilesystem();
205205
return ret;
206206
}
207207

208208
int File::available (void)
209209
{
210210
int ret = 0;
211-
this->DoNotCallFromOutsideClass_LockFilesystem();
211+
this->_LockFilesystem();
212212
if (!this->_is_dir)
213213
{
214214
uint32_t size = lfs_file_size(_fs->getFS(), _file);
215215
uint32_t pos = lfs_file_tell(_fs->getFS(), _file);
216216
ret = size - pos;
217217
}
218-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
218+
this->_UnlockFilesystem();
219219
return ret;
220220
}
221221

222222
bool File::seek (uint32_t pos)
223223
{
224224
bool ret = false;
225-
this->DoNotCallFromOutsideClass_LockFilesystem();
225+
this->_LockFilesystem();
226226
if (!this->_is_dir)
227227
{
228228
ret = lfs_file_seek(_fs->getFS(), _file, pos, LFS_SEEK_SET) >= 0;
229229
}
230-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
230+
this->_UnlockFilesystem();
231231
return ret;
232232
}
233233

234234
uint32_t File::position (void)
235235
{
236236
uint32_t ret = 0;
237-
this->DoNotCallFromOutsideClass_LockFilesystem();
237+
this->_LockFilesystem();
238238
if (!this->_is_dir)
239239
{
240240
ret = lfs_file_tell(_fs->getFS(), _file);
241241
}
242-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
242+
this->_UnlockFilesystem();
243243
return ret;
244244
}
245245

246246
uint32_t File::size (void)
247247
{
248248
uint32_t ret = 0;
249-
this->DoNotCallFromOutsideClass_LockFilesystem();
249+
this->_LockFilesystem();
250250
if (!this->_is_dir)
251251
{
252252
ret = lfs_file_size(_fs->getFS(), _file);
253253
}
254-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
254+
this->_UnlockFilesystem();
255255
return ret;
256256

257257
}
258258

259259
void File::flush (void)
260260
{
261-
this->DoNotCallFromOutsideClass_LockFilesystem();
261+
this->_LockFilesystem();
262262
if (!this->_is_dir)
263263
{
264264
lfs_file_sync(_fs->getFS(), _file);
265265
}
266-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
266+
this->_UnlockFilesystem();
267267
return;
268268
}
269269

270270
void File::close (void)
271271
{
272-
this->DoNotCallFromOutsideClass_LockFilesystem();
272+
this->_LockFilesystem();
273273
this->_close();
274-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
274+
this->_UnlockFilesystem();
275275
}
276276
void File::_close(void)
277277
{
@@ -302,9 +302,9 @@ File::operator bool (void)
302302
bool File::isOpen(void)
303303
{
304304
bool ret = 0;
305-
this->DoNotCallFromOutsideClass_LockFilesystem();
305+
this->_LockFilesystem();
306306
ret = this->_isOpen();
307-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
307+
this->_UnlockFilesystem();
308308
return ret;
309309
}
310310
bool File::_isOpen(void)
@@ -319,24 +319,24 @@ bool File::_isOpen(void)
319319
// suddenly (unexpectedly?) have different values.
320320
char const* File::name (void)
321321
{
322-
this->DoNotCallFromOutsideClass_LockFilesystem();
322+
this->_LockFilesystem();
323323
char const* ret = this->_name;
324-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
324+
this->_UnlockFilesystem();
325325
return ret;
326326
}
327327

328328
bool File::isDirectory (void)
329329
{
330-
this->DoNotCallFromOutsideClass_LockFilesystem();
330+
this->_LockFilesystem();
331331
bool ret = this->_is_dir;
332-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
332+
this->_UnlockFilesystem();
333333
return ret;
334334

335335
}
336336

337337
File File::openNextFile (uint8_t mode)
338338
{
339-
this->DoNotCallFromOutsideClass_LockFilesystem();
339+
this->_LockFilesystem();
340340

341341
File ret(*_fs);
342342
if (this->_is_dir)
@@ -366,26 +366,26 @@ File File::openNextFile (uint8_t mode)
366366
PRINT_LFS_ERR(rc);
367367
}
368368
}
369-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
369+
this->_UnlockFilesystem();
370370
return ret;
371371
}
372372

373373
void File::rewindDirectory (void)
374374
{
375-
this->DoNotCallFromOutsideClass_LockFilesystem();
375+
this->_LockFilesystem();
376376
if (this->_is_dir)
377377
{
378378
lfs_dir_rewind(_fs->getFS(), _dir);
379379
}
380-
this->DoNotCallFromOutsideClass_UnlockFilesystem();
380+
this->_UnlockFilesystem();
381381
return;
382382
}
383383

384-
void File::DoNotCallFromOutsideClass_LockFilesystem(void)
384+
void File::_LockFilesystem(void)
385385
{
386386
xSemaphoreTake(this->_fs->_mutex, portMAX_DELAY);
387387
}
388-
void File::DoNotCallFromOutsideClass_UnlockFilesystem(void)
388+
void File::_UnlockFilesystem(void)
389389
{
390390
xSemaphoreGive(this->_fs->_mutex);
391391
}

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class File : public Stream
8282
void rewindDirectory (void);
8383

8484
// Has to be public, in order to grant 'friend' permissions to Adafruit_LittleFS private member _mutex
85-
void DoNotCallFromOutsideClass_LockFilesystem(void);
86-
void DoNotCallFromOutsideClass_UnlockFilesystem(void);
85+
void _LockFilesystem(void);
86+
void _UnlockFilesystem(void);
8787

8888
private:
8989
Adafruit_LittleFS* _fs;

0 commit comments

Comments
 (0)