correct FILE_WRITE to be opened at the end of file for lfs

This commit is contained in:
hathach committed 2018-10-24 22:19:49 +07:00
1 parent 6755a25d02
commit 7a23c671fd
3 files changed
+5 -4

No files matched your search

+4 -2
View File
@@ -216,8 +216,7 @@ BluefuritLib::File LittleFS::_open_file (char const *filepath, uint8_t mode)
BluefuritLib::File file(*this);
int flags = (mode == FILE_READ) ? LFS_O_RDONLY :
(mode == FILE_WRITE) ? (LFS_O_RDWR | LFS_O_CREAT) :
(mode == FILE_APPEND) ? (LFS_O_RDWR | LFS_O_CREAT | LFS_O_APPEND) : 0;
(mode == FILE_WRITE) ? (LFS_O_RDWR | LFS_O_CREAT) : 0;
if ( flags )
{
@@ -231,6 +230,9 @@ BluefuritLib::File LittleFS::_open_file (char const *filepath, uint8_t mode)
}
else
{
// move to end of file
if ( mode == FILE_WRITE ) lfs_file_seek(&_lfs, fhdl, 0, LFS_SEEK_END);
file._hdl = fhdl;
file._is_dir = false;