Difference between revisions of "love.filesystem.newFile"

(Added new 0.9.0 variant)
(added apparent restriction on ':' in filenames on at least Linux and OS X)
Line 8: Line 8:
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|string|filename|The filename of the file.}}
+
{{param|string|filename|The filename of the file. (Note that ':' may not occur in a filename.)}}
 
=== Returns ===
 
=== Returns ===
 
{{param|File|file|The new File object.}}
 
{{param|File|file|The new File object.}}

Revision as of 00:16, 12 August 2014

Creates a new File object. It needs to be opened before it can be accessed.

Function

Synopsis

file = love.filesystem.newFile( filename )

Arguments

string filename
The filename of the file. (Note that ':' may not occur in a filename.)

Returns

File file
The new File object.

Function

Available since LÖVE 0.9.0
This variant is not supported in earlier versions.

Creates a File object and opens it for reading, writing, or appending.

Synopsis

file, errorstr = love.filesystem.newFile( 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.newFile("data.txt")
file:open("r")
data = file:read()

See Also


Other Languages