mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 02:19:44 +00:00
fix
This commit is contained in:
parent
682ca665c9
commit
5fd3ce76da
1 changed files with 5 additions and 4 deletions
|
|
@ -305,13 +305,14 @@ static int l_read_descriptor(lua::State* L) {
|
||||||
int maxlen = lua::tointeger(L, 2);
|
int maxlen = lua::tointeger(L, 2);
|
||||||
|
|
||||||
auto& stream = io_descriptors::require_input(descriptor);
|
auto& stream = io_descriptors::require_input(descriptor);
|
||||||
if (stream.eof()) {
|
|
||||||
stream.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
util::Buffer<char> buffer(maxlen);
|
util::Buffer<char> buffer(maxlen);
|
||||||
stream.read(buffer.data(), maxlen);
|
stream.read(buffer.data(), maxlen);
|
||||||
std::streamsize read_len = stream.gcount();
|
std::streamsize read_len = stream.gcount();
|
||||||
|
|
||||||
|
if (stream.eof()) {
|
||||||
|
stream.clear(stream.rdstate() & std::ios::badbit);
|
||||||
|
}
|
||||||
return lua::create_bytearray(L, buffer.data(), read_len);
|
return lua::create_bytearray(L, buffer.data(), read_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue