@@ -36,7 +36,7 @@ using namespace LittleFilesystem;
36
36
File::File (Adafruit_LittleFS &fs)
37
37
{
38
38
_fs = &fs;
39
- _hdl = NULL ;
39
+ _file = NULL ;
40
40
_dir = NULL ;
41
41
_path = NULL ;
42
42
_is_dir = false ;
@@ -45,7 +45,7 @@ File::File (Adafruit_LittleFS &fs)
45
45
File::File (char const *filename, uint8_t mode, Adafruit_LittleFS &fs)
46
46
{
47
47
_fs = &fs;
48
- _hdl = NULL ;
48
+ _file = NULL ;
49
49
_dir = NULL ;
50
50
_path = NULL ;
51
51
_is_dir = false ;
@@ -56,7 +56,7 @@ File::File (char const *filename, uint8_t mode, Adafruit_LittleFS &fs)
56
56
File& File::operator = (const File &rhs)
57
57
{
58
58
// close if currently opened
59
- if ( _hdl ) close ();
59
+ if ( _file ) close ();
60
60
memcpy (this , &rhs, sizeof (File));
61
61
return *this ;
62
62
}
@@ -90,7 +90,7 @@ File File::_open_file (char const *filepath, uint8_t mode)
90
90
// move to end of file
91
91
if ( mode == FILE_WRITE ) lfs_file_seek (_fs->getFS (), fhdl, 0 , LFS_SEEK_END);
92
92
93
- file._hdl = fhdl;
93
+ file._file = fhdl;
94
94
file._is_dir = false ;
95
95
96
96
file._path = (char *) rtos_malloc (strlen (filepath) + 1 );
@@ -128,7 +128,7 @@ File File::_open_dir (char const *filepath)
128
128
bool File::open (char const *filepath, uint8_t mode)
129
129
{
130
130
// close if currently opened
131
- if ( _hdl ) close ();
131
+ if ( _file ) close ();
132
132
133
133
File file (*_fs);
134
134
struct lfs_info info;
@@ -149,7 +149,7 @@ bool File::open (char const *filepath, uint8_t mode)
149
149
PRINT_LFS_ERR (rc);
150
150
}
151
151
152
- return _hdl != NULL ;
152
+ return _file != NULL ;
153
153
}
154
154
155
155
size_t File::write (uint8_t ch)
@@ -162,7 +162,7 @@ size_t File::write (uint8_t const *buf, size_t size)
162
162
{
163
163
VERIFY (!_is_dir, 0 );
164
164
165
- lfs_ssize_t wrcount = lfs_file_write (_fs->getFS (), _hdl , buf, size);
165
+ lfs_ssize_t wrcount = lfs_file_write (_fs->getFS (), _file , buf, size);
166
166
VERIFY (wrcount > 0 , 0 );
167
167
return wrcount;
168
168
}
@@ -177,7 +177,7 @@ int File::read (void)
177
177
int File::read (void *buf, uint16_t nbyte)
178
178
{
179
179
VERIFY (!_is_dir, 0 );
180
- return lfs_file_read (_fs->getFS (), _hdl , buf, nbyte);
180
+ return lfs_file_read (_fs->getFS (), _file , buf, nbyte);
181
181
}
182
182
183
183
int File::peek (void )
@@ -198,52 +198,52 @@ int File::available (void)
198
198
bool File::seek (uint32_t pos)
199
199
{
200
200
VERIFY (!_is_dir, false );
201
- return lfs_file_seek (_fs->getFS (), _hdl , pos, LFS_SEEK_SET) >= 0 ;
201
+ return lfs_file_seek (_fs->getFS (), _file , pos, LFS_SEEK_SET) >= 0 ;
202
202
}
203
203
204
204
uint32_t File::position (void )
205
205
{
206
206
VERIFY (!_is_dir, 0 );
207
- return lfs_file_tell (_fs->getFS (), _hdl );
207
+ return lfs_file_tell (_fs->getFS (), _file );
208
208
}
209
209
210
210
uint32_t File::size (void )
211
211
{
212
212
VERIFY (!_is_dir, 0 );
213
- return lfs_file_size (_fs->getFS (), _hdl );
213
+ return lfs_file_size (_fs->getFS (), _file );
214
214
}
215
215
216
216
void File::flush (void )
217
217
{
218
218
VERIFY (!_is_dir,);
219
- lfs_file_sync (_fs->getFS (), _hdl );
219
+ lfs_file_sync (_fs->getFS (), _file );
220
220
}
221
221
222
222
void File::close (void )
223
223
{
224
- if ( _hdl )
224
+ if ( _file )
225
225
{
226
226
if ( _is_dir )
227
227
{
228
228
lfs_dir_close (_fs->getFS (), _dir);
229
229
}
230
230
else
231
231
{
232
- lfs_file_close (_fs->getFS (), _hdl );
232
+ lfs_file_close (_fs->getFS (), _file );
233
233
}
234
234
235
- rtos_free (_hdl );
235
+ rtos_free (_file );
236
236
}
237
237
238
238
if ( _path ) rtos_free (_path);
239
239
240
- _hdl = NULL ;
240
+ _file = NULL ;
241
241
_path = NULL ;
242
242
}
243
243
244
244
File::operator bool (void )
245
245
{
246
- return _hdl != NULL ;
246
+ return _file != NULL ;
247
247
}
248
248
249
249
char const * File::name (void )
0 commit comments