Difference between revisions of "love.filesystem.openFile"

(Created page)
 
m
Line 1: Line 1:
{{newin|[[12.0]]|120|type=function}}
+
{{newin|[[12.0]]|120|type=function|text=This function replaces [[love.filesystem.newFile]]}}
  
 
Opens a new [[File]] object, which represents an existing or new file on disk.
 
Opens a new [[File]] object, which represents an existing or new file on disk.

Revision as of 02:11, 11 November 2022

Available since LÖVE 12.0
This function replaces love.filesystem.newFile.


Opens a new File object, which represents an existing or new file on disk.

Function

Synopsis

file, errorstr = love.filesystem.openFile( filename, mode )

Arguments

string filename
The filename of the file.
FileMode mode
The mode to open the file in.

Returns

File file
The new File object, or nil if an error occurred.
string errorstr
The error string if an error occurred.

Examples

Open a file and read everything

file = love.filesystem.openFile("data.txt", "r")
data = file:read()
file:close()
-- use the data ...

See Also

Other Languages