Difference between revisions of "love.filesystem.openFile"
(Created page) |
m |
||
(One intermediate revision by the same user not shown) | |||
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. | ||
Line 14: | Line 14: | ||
{{param|File|file|The new File object, or nil if an error occurred.}} | {{param|File|file|The new File object, or nil if an error occurred.}} | ||
{{param|string|errorstr|The error string if an error occurred.}} | {{param|string|errorstr|The error string if an error occurred.}} | ||
+ | |||
+ | == Notes == | ||
+ | [[love.filesystem.read]], [[love.filesystem.write]], and [[love.filesystem.append]] are more convenient functions to use in situations where a file is operated on once rather than multiple times. | ||
== Examples == | == Examples == |
Latest revision as of 02:13, 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.
Contents
Function
Synopsis
file, errorstr = love.filesystem.openFile( 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.
Notes
love.filesystem.read, love.filesystem.write, and love.filesystem.append are more convenient functions to use in situations where a file is operated on once rather than multiple times.
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
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