Change read to return LFS return values when reading a directory or nonexistant file

This commit is contained in:
Tim Keller 2021-11-20 20:18:14 +00:00
parent 09b9130244
commit b62c62ee1f

View file

@ -89,7 +89,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
resp.chunkoff = header->chunkoff; resp.chunkoff = header->chunkoff;
int res = fs.Stat(filepath, &info); int res = fs.Stat(filepath, &info);
if (res == LFS_ERR_NOENT && info.type != LFS_TYPE_DIR) { if (res == LFS_ERR_NOENT && info.type != LFS_TYPE_DIR) {
resp.status = 0x03; resp.status = (int8_t) res;
resp.chunklen = 0; resp.chunklen = 0;
resp.totallen = 0; resp.totallen = 0;
om = ble_hs_mbuf_from_flat(&resp, sizeof(ReadResponse)); om = ble_hs_mbuf_from_flat(&resp, sizeof(ReadResponse));
@ -118,7 +118,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
resp.chunkoff = header->chunkoff; resp.chunkoff = header->chunkoff;
int res = fs.Stat(filepath, &info); int res = fs.Stat(filepath, &info);
if (res == LFS_ERR_NOENT && info.type != LFS_TYPE_DIR) { if (res == LFS_ERR_NOENT && info.type != LFS_TYPE_DIR) {
resp.status = 0x03; resp.status = (int8_t) res;
resp.chunklen = 0; resp.chunklen = 0;
resp.totallen = 0; resp.totallen = 0;
} else { } else {
@ -171,7 +171,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
WriteResponse resp; WriteResponse resp;
resp.command = commands::WRITE_PACING; resp.command = commands::WRITE_PACING;
resp.offset = header->offset; resp.offset = header->offset;
resp.status = 1; resp.status = 0x01;
fs.FileOpen(&f, filepath, LFS_O_RDWR | LFS_O_CREAT); fs.FileOpen(&f, filepath, LFS_O_RDWR | LFS_O_CREAT);
fs.FileSeek(&f, header->offset); fs.FileSeek(&f, header->offset);
int res = fs.FileWrite(&f, header->data, header->dataSize); int res = fs.FileWrite(&f, header->data, header->dataSize);
@ -226,7 +226,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
ListDirResponse resp {}; ListDirResponse resp {};
resp.command = commands::LISTDIR_ENTRY; resp.command = commands::LISTDIR_ENTRY;
resp.status = 1; resp.status = 0x01;
resp.totalentries = 0; resp.totalentries = 0;
resp.entry = 0; resp.entry = 0;
resp.modification_time = 0; resp.modification_time = 0;