openFile

From GTA Connected
(Redirected from OpenFile)
Jump to: navigation, search

Function Server and Client All Games Online and Offline

Server 1.0.0, Client 1.0.0

Stream openFile(string filePath, [ bool writable = false ])

Description

The openFile function is used to open a handle to a file on the hard drive, fetching a Stream object on success.
The file is opened in binary mode, not text mode.
The initial seek position is 0.
If parameter Writable is bool true, the file is created if it doesn't exist.

Parameters

Type Name Presence Default Value Description
string filePath required n/a The path to the file.
bool writable optional false Whether to open the file in writable mode.

Returns

Success Returns

Type Description
Stream A handle to the file stream.

Failure Returns

Type Value
null n/a

Notes

There aren't any notes for this function.

Examples

Example 1 - JavaScript:

file = openFile("test.txt", true)
if (file != null) {
    file.writeString("this is a test")
    file.close()
}


Example 2 - Lua:

file = openFile("test.txt", true)
if file ~= nil then
    file:writeString("this is a test")
    file:close()
end

Compatibility

There isn't any compatibility information for this function.

Related

Server Related

createFile
openFile


Client Related

createFile
openFile