M MY Multiplayer: Wiki
Side
Kind

fileRead

Shared

Reads bytes from a file at the current position and moves the position on.

string fileRead(file file, int count)

Parameters

NameTypeDescription
filefileA file opened by fileOpen or fileCreate.
countintHow many bytes to read, 0 or more.

Returns

The bytes read. It may hold fewer than count (or be empty) near the end.

Example

local file = fileOpen("data.bin", true)
while file and not fileIsEOF(file) do
    local chunk = fileRead(file, 4096)
    print(#chunk)
end
if file then fileClose(file) end

See also