From Multi Theft Auto: Wiki

This function returns whether a stream is readable. If a stream is not readable, then all read operations should result in nil operations (they will return zero bytes read or false if value reading). This state should be immutable across the lifetime of a file/stream class.


boolean file.isReadable ()


Returns true if the file/stream is readable, false otherwise.


Click to collapse [-]

This snippet is the counterpart of the file.isWritable example. It attempts to read the header from the file, but throws an exception if it cannot be read from.

local function readHeader( theFile )
    -- Check whether we can read anything from the file.
    if not ( theFile.isReadable() ) then
        error( "fatal error: file cannot be read from" );

    -- Read the generic header back into the engine.
    local headerInfo = {
        chunkSize = theFile.readUInt(),
        version = theFile.readFloat(),
        isRaw = theFile.readBoolean()

    -- Return the header information.
    return headerInfo;

FileSystem File Functions