Skip to main content

Read all data from a file (file.reads)

Declaration

data, err = file.reads(path)

Parameters

  • path
    String. Absolute file path.

Returns

  • data
    String or nil. nil if file does not exist; otherwise the entire file contents.
  • err
    String. Error message when operation fails.

Notes

Read all data from a file.

Example

local data, err = file.reads("/var/mobile/1.zip")
if data then
sys.alert("/var/mobile/1.zip size: "..#data.." bytes")
else
sys.alert("Read failed: "..err)
end

Note: Uses sys.alert