mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
fix of io_stream:read_fully for binary and yield mode
This commit is contained in:
parent
5424f51f70
commit
fdec2d722d
1 changed files with 8 additions and 2 deletions
|
|
@ -145,8 +145,12 @@ function io_stream:__update_read_buffer()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function io_stream:__read(length)
|
function io_stream:__read(length, fromReadFully)
|
||||||
if self.mode == YIELD_MODE then
|
if self.mode == YIELD_MODE then
|
||||||
|
if fromReadFully then
|
||||||
|
return self.ioLib.read(self.descriptor, length)
|
||||||
|
end
|
||||||
|
|
||||||
local buffer = Bytearray()
|
local buffer = Bytearray()
|
||||||
|
|
||||||
while #buffer < length do
|
while #buffer < length do
|
||||||
|
|
@ -203,7 +207,9 @@ function io_stream:read_fully(useTable)
|
||||||
if self.binaryMode then
|
if self.binaryMode then
|
||||||
local result = useTable and Bytearray() or { }
|
local result = useTable and Bytearray() or { }
|
||||||
|
|
||||||
readFully(result, function() return self:__read(self.maxBufferSize) end)
|
readFully(result, function() return self:__read(self.maxBufferSize, true) end)
|
||||||
|
|
||||||
|
return result
|
||||||
else
|
else
|
||||||
if useTable then
|
if useTable then
|
||||||
local lines = { }
|
local lines = { }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue