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