fix(simu): reset error bits on stream after incomplete read (#6566)
This commit is contained in:
@@ -318,6 +318,7 @@ FRESULT f_read(FIL* fil, void* data, UINT size, UINT* read)
|
|||||||
sf->stream->read(static_cast<char*>(data), size);
|
sf->stream->read(static_cast<char*>(data), size);
|
||||||
*read = static_cast<UINT>(sf->stream->gcount());
|
*read = static_cast<UINT>(sf->stream->gcount());
|
||||||
fil->fptr += *read;
|
fil->fptr += *read;
|
||||||
|
sf->stream->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include "edgetx.h"
|
#include "edgetx.h"
|
||||||
#include "lua/lua_states.h"
|
#include "lua/lua_states.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#define MIXSRC_THR (MIXSRC_FIRST_STICK + inputMappingGetThrottle())
|
#define MIXSRC_THR (MIXSRC_FIRST_STICK + inputMappingGetThrottle())
|
||||||
#define MIXSRC_TRIMTHR (MIXSRC_FIRST_TRIM + inputMappingGetThrottle())
|
#define MIXSRC_TRIMTHR (MIXSRC_FIRST_TRIM + inputMappingGetThrottle())
|
||||||
|
|
||||||
@@ -220,4 +222,25 @@ TEST(Lua, testLegacyNames)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Lua, ioSeek)
|
||||||
|
{
|
||||||
|
const char io_seek_tst[] =
|
||||||
|
"local file_name = \"seek-test.txt\"\n"
|
||||||
|
"local file = io.open(file_name, \"w\")\n"
|
||||||
|
"io.write(file, \"abcd\")\n"
|
||||||
|
"io.close(file)\n"
|
||||||
|
"file = io.open(file_name, \"r\")\n"
|
||||||
|
// the file should have 4 characters
|
||||||
|
"assert(#io.read(file, 32) == 4)\n"
|
||||||
|
// io.seek() should return 0 if it is successful
|
||||||
|
"assert(io.seek(file, 2) == 0)\n"
|
||||||
|
"local r = io.read(file, 32)\n"
|
||||||
|
// if reading from position 2,
|
||||||
|
// we should read 2 characters,
|
||||||
|
"assert(#r == 2)\n";
|
||||||
|
|
||||||
|
luaExecStr(io_seek_tst);
|
||||||
|
std::filesystem::remove(simuFatfsGetRealPath("seek-test.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
#endif // #if defined(LUA)
|
#endif // #if defined(LUA)
|
||||||
|
|||||||
Reference in New Issue
Block a user