Io.open: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === This function opens a file, in the mode specified in the string mode. It returns a new file handle, or..."
 
No edit summary
Line 16: Line 16:
  The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode. This string is exactly what is used in the standard C function fopen.
  The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode. This string is exactly what is used in the standard C function fopen.
<source lang="lua">
<source lang="lua">
(file), = io.open(filenamemode,)
(file) = io.open(filename,mode)
</source>
</source>
'''filename:''' (string) filename to open ''''''<br/>
'''filename''': (string) filename to open ''''''<br/>
'''mode:''' (string) mode in which to open the file '''optional'''<br/>
'''mode''': (string) mode in which to open the file '''optional'''<br/>
'''Returns''' (file) file object<br/>
'''Returns''' (file) file object<br/>

Revision as of 09:16, 23 August 2018

Available since: Gideros 2011.6

Description

This function opens a file, in the mode specified in the string mode. It returns a new file handle, or, in case of errors, nil plus an error message.


The mode string can be any of the following: 

"r": read mode (the default); "w": write mode; "a": append mode; "r+": update mode, all previous data is preserved; "w+": update mode, all previous data is erased; "a+": append update mode, previous data is preserved, writing is only allowed at the end of file.

The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode. This string is exactly what is used in the standard C function fopen.
(file) = io.open(filename,mode)

'filename: (string) filename to open '
mode: (string) mode in which to open the file optional
Returns (file) file object