mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
LittleFS: add overrides for Stream::send (#8386)
* littlefs: add overrides for Stream::send
This commit is contained in:
@ -241,7 +241,7 @@ public:
|
||||
DEBUGV("lfs_format, lfs_setattr 't': rc=%d\n", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
lfs_unmount(&_lfs);
|
||||
_mounted = false;
|
||||
}
|
||||
@ -372,6 +372,30 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int availableForWrite () override {
|
||||
if (!_opened || !_fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto f = _getFD();
|
||||
const auto fs = _fs->getFS();
|
||||
|
||||
// check for remaining size in current block
|
||||
// ignore inline feature (per code in lfs_file_rawwrite())
|
||||
auto afw = fs->cfg->block_size - f->off;
|
||||
|
||||
if (afw == 0) {
|
||||
// current block is full
|
||||
// check for filesystem full (per code in lfs_alloc())
|
||||
if (!(fs->free.i == fs->free.size && fs->free.ack == 0)) {
|
||||
// fs is not full, return a full sector as free space
|
||||
afw = fs->cfg->block_size;
|
||||
}
|
||||
}
|
||||
|
||||
return afw;
|
||||
}
|
||||
|
||||
size_t write(const uint8_t *buf, size_t size) override {
|
||||
if (!_opened || !_fd || !buf) {
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user