Difference between revisions of "love.filesystem.newFile"
(Added new 0.9.0 variant) |
|||
Line 1: | Line 1: | ||
Creates a new [[File]] object. | Creates a new [[File]] object. | ||
It needs to be opened before it can be accessed. | It needs to be opened before it can be accessed. | ||
+ | |||
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
Line 7: | Line 8: | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|string|filename|The filename of the file | + | {{param|string|filename|The filename of the file.}} |
=== Returns === | === Returns === | ||
{{param|File|file|The new File object.}} | {{param|File|file|The new File object.}} | ||
+ | |||
+ | == Function == | ||
+ | {{newin|[[0.9.0]]|090|type=variant}} | ||
+ | Creates a [[File]] object and opens it for reading, writing, or appending. | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | file, errorstr = love.filesystem.newFile( filename, mode ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|string|filename|The filename of the file.}} | ||
+ | {{param|FileMode|mode|The mode to open the file in.}} | ||
+ | === Returns === | ||
+ | {{param|File|file|The new File object, or nil if an error occurred.}} | ||
+ | {{param|string|errorstr|The error string if an error occurred.}} | ||
+ | |||
== Examples == | == Examples == | ||
=== Open a file and read everything === | === Open a file and read everything === | ||
<source lang="lua"> | <source lang="lua"> | ||
file = love.filesystem.newFile("data.txt") | file = love.filesystem.newFile("data.txt") | ||
− | file:open( | + | file:open("r") |
data = file:read() | data = file:read() | ||
</source> | </source> |
Revision as of 01:45, 25 August 2013
Creates a new File object. It needs to be opened before it can be accessed.
Contents
Function
Synopsis
file = love.filesystem.newFile( filename )
Arguments
string filename
- The filename of the file.
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
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
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info