Skip to content

Commit fe375eb

Browse files
committed
clean up lfs
1 parent 616162f commit fe375eb

File tree

1 file changed

+1
-144
lines changed

1 file changed

+1
-144
lines changed

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.cpp

Lines changed: 1 addition & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -150,67 +150,6 @@ bool Adafruit_LittleFS::format (bool eraseall)
150150
return true;
151151
}
152152

153-
#if 0
154-
LittleFilesystem::File Adafruit_LittleFS::_open_file (char const *filepath, uint8_t mode)
155-
{
156-
LittleFilesystem::File file(*this);
157-
158-
int flags = (mode == FILE_READ) ? LFS_O_RDONLY :
159-
(mode == FILE_WRITE) ? (LFS_O_RDWR | LFS_O_CREAT) : 0;
160-
161-
if ( flags )
162-
{
163-
lfs_file_t* fhdl = (lfs_file_t*) rtos_malloc(sizeof(lfs_file_t));
164-
VERIFY(fhdl, file);
165-
166-
int rc = lfs_file_open(&_lfs, fhdl, filepath, flags);
167-
168-
if ( rc )
169-
{
170-
rtos_free(fhdl);
171-
PRINT_LFS_ERR(rc);
172-
}
173-
else
174-
{
175-
// move to end of file
176-
if ( mode == FILE_WRITE ) lfs_file_seek(&_lfs, fhdl, 0, LFS_SEEK_END);
177-
178-
file._hdl = fhdl;
179-
file._is_dir = false;
180-
181-
file._path = (char*) rtos_malloc(strlen(filepath) + 1);
182-
strcpy(file._path, filepath);
183-
}
184-
}
185-
186-
return file;
187-
}
188-
189-
LittleFilesystem::File Adafruit_LittleFS::_open_dir (char const *filepath)
190-
{
191-
LittleFilesystem::File file(*this);
192-
193-
lfs_dir_t* fhdl = (lfs_dir_t*) rtos_malloc(sizeof(lfs_dir_t));
194-
int rc = lfs_dir_open(&_lfs, fhdl, filepath);
195-
196-
if ( rc )
197-
{
198-
rtos_free(fhdl);
199-
PRINT_LFS_ERR(rc);
200-
}
201-
else
202-
{
203-
file._hdl = fhdl;
204-
file._is_dir = true;
205-
206-
file._path = (char*) rtos_malloc(strlen(filepath) + 1);
207-
strcpy(file._path, filepath);
208-
}
209-
210-
return file;
211-
}
212-
#endif
213-
214153
LittleFilesystem::File Adafruit_LittleFS::open (char const *filepath, uint8_t mode)
215154
{
216155
return LittleFilesystem::File(filepath, mode, *this);
@@ -275,90 +214,8 @@ bool Adafruit_LittleFS::rmdir_r (char const *filepath)
275214
}
276215

277216
//--------------------------------------------------------------------+
278-
// FILE API
217+
// flash API
279218
//--------------------------------------------------------------------+
280-
//size_t Adafruit_LittleFS::_f_write (void* fhdl, uint8_t const *buf, size_t size)
281-
//{
282-
// lfs_ssize_t wrcount = lfs_file_write(&_lfs, (lfs_file_t*) fhdl, buf, size);
283-
// VERIFY(wrcount > 0, 0);
284-
// return wrcount;
285-
//}
286-
287-
//void Adafruit_LittleFS::_f_flush (void* fhdl)
288-
//{
289-
// VERIFY_LFS(lfs_file_sync(&_lfs, (lfs_file_t* ) fhdl),);
290-
//}
291-
292-
//int Adafruit_LittleFS::_f_read (void* fhdl, void *buf, uint16_t nbyte)
293-
//{
294-
// return lfs_file_read(&_lfs, (lfs_file_t*) fhdl, buf, nbyte);
295-
//}
296-
//
297-
//bool Adafruit_LittleFS::_f_seek (void* fhdl, uint32_t pos)
298-
//{
299-
// return lfs_file_seek(&_lfs, (lfs_file_t*) fhdl, pos, LFS_SEEK_SET) >= 0;
300-
//}
301-
302-
//uint32_t Adafruit_LittleFS::_f_position (void* fhdl)
303-
//{
304-
// return lfs_file_tell(&_lfs, (lfs_file_t*) fhdl);
305-
//}
306-
307-
//uint32_t Adafruit_LittleFS::_f_size (void* fhdl)
308-
//{
309-
// return lfs_file_size(&_lfs, (lfs_file_t*) fhdl);
310-
//}
311-
312-
//void Adafruit_LittleFS::_f_close (void* fhdl, bool is_dir)
313-
//{
314-
// if ( is_dir )
315-
// {
316-
// lfs_dir_close(&_lfs, (lfs_dir_t *) fhdl);
317-
// }
318-
// else
319-
// {
320-
// lfs_file_close(&_lfs, (lfs_file_t*) fhdl);
321-
// }
322-
//}
323-
324-
//File Adafruit_LittleFS::_f_openNextFile (void* fhdl, char const* cwd, uint8_t mode)
325-
//{
326-
// LittleFilesystem::File file(*this);
327-
// struct lfs_info info;
328-
//
329-
// int rc;
330-
//
331-
// // lfs_dir_read return 0 when reaching end of directory, 1 if found an entry
332-
// // skip "." and ".." entries
333-
// do
334-
// {
335-
// rc = lfs_dir_read(&_lfs, (lfs_dir_t *) fhdl, &info);
336-
// } while ( rc == 1 && (!strcmp(".", info.name) || !strcmp("..", info.name)) );
337-
//
338-
// if ( rc == 1 )
339-
// {
340-
// // string cat name with current folder
341-
// char filepath[strlen(cwd) + 1 + strlen(info.name) + 1];
342-
//
343-
// strcpy(filepath, cwd);
344-
// if ( !(cwd[0] == '/' && cwd[1] == 0) ) strcat(filepath, "/"); // only add '/' if cwd is not root
345-
// strcat(filepath, info.name);
346-
//
347-
// file = (info.type == LFS_TYPE_REG) ? _open_file(filepath, mode) : _open_dir(filepath);
348-
// }
349-
// else if ( rc < 0 )
350-
// {
351-
// PRINT_LFS_ERR(rc);
352-
// }
353-
//
354-
// return file;
355-
//}
356-
357-
//void Adafruit_LittleFS::_f_rewindDirectory (void* fhdl)
358-
//{
359-
// VERIFY_LFS(lfs_dir_rewind(&_lfs, (lfs_dir_t* ) fhdl),);
360-
//}
361-
362219

363220
int Adafruit_LittleFS::_flash_read (lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size)
364221
{

0 commit comments

Comments
 (0)