MTA:Eir/FileSystem/file/isReadable
Jump to navigation
Jump to search
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.
Syntax
boolean file.isReadable ()
Returns
Returns true if the file/stream is readable, false otherwise.
Example
Click to collapse [-]
ClientThis 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" ); end -- 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; end