- Documentation
- Shared functions
- fileRead
Function
fileRead
Reads the given number of bytes from the current position and moves the position. At the end of the file it returns an empty string. Binary data is returned unchanged.
Syntax
string fileRead(file theFile, int count)Arguments
theFilefile- A file handle.
countint- Number of bytes.
Returns
The data read, or false.
Example
local file = fileOpen("data.bin", true)
if file then
while not fileIsEOF(file) do
local chunk = fileRead(file, 500)
outputDebugString(#chunk .. " bajtow")
end
fileClose(file)
end
See also
fileWriteWrites strings from the current position (each argument one after another) and moves the position. Supports binary data.fileGetContentsReads a whole file in one call. Accepts a file handle or a path (it then opens and closes the file itself).fileIsEOFChecks whether the file position has reached the end.