Difference between revisions of "love.filesystem.newFileData"
m (→Function: changed term (A storage is not only a hard drive).) |
m (Added new Data variant in 11.4) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | Creates a new [[FileData]] object. | + | Creates a new [[FileData]] object from a file on disk, or from a string in memory. |
== Function == | == Function == | ||
+ | Creates a new FileData object from a string in memory. | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | data = love.filesystem.newFileData( contents, name, | + | data = love.filesystem.newFileData( contents, name ) |
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|string|contents|The contents of the file in memory represented as a string.}} | ||
+ | {{param|string|name|The name of the file. The extension may be parsed and used by LÖVE when passing the FileData object into [[love.audio.newSource]].}} | ||
+ | === Returns === | ||
+ | {{param|FileData|data|The new FileData.}} | ||
+ | |||
+ | == Function == | ||
+ | {{newin|[[11.4]]|114|type=variant}} | ||
+ | Creates a new FileData object from a [[Data]] object in memory. | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | data = love.filesystem.newFileData( originaldata, name ) | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param| | + | {{param|Data|originaldata|The Data object to copy into the new FileData object.}} |
− | {{param|string|name|The name of the file. | + | {{param|string|name|The name of the file. The extension may be parsed and used by LÖVE when passing the FileData object into [[love.audio.newSource]].}} |
− | |||
=== Returns === | === Returns === | ||
− | {{param|FileData|data| | + | {{param|FileData|data|The new FileData.}} |
== Function == | == Function == | ||
Line 25: | Line 38: | ||
{{param|FileData|data|The new FileData, or [[nil]] if an error occurred.}} | {{param|FileData|data|The new FileData, or [[nil]] if an error occurred.}} | ||
{{param|string|err|The error string, if an error occurred.}} | {{param|string|err|The error string, if an error occurred.}} | ||
+ | |||
+ | == Function == | ||
+ | {{oldin|[[11.0]]|110|type=variant|text=The variant which decodes base64 data has been replaced by [[love.data.decode]]}} | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | data = love.filesystem.newFileData( contents, name, decoder ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|string|contents|The contents of the file.}} | ||
+ | {{param|string|name|The name of the file.}} | ||
+ | {{param|FileDecoder|decoder|The method to use when decoding the contents.}} | ||
+ | === Returns === | ||
+ | {{param|FileData|data|Your new FileData.}} | ||
== See Also == | == See Also == | ||
Line 30: | Line 56: | ||
* [[Constructs::FileData]] | * [[Constructs::FileData]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | {{#set:Description=Creates a new [[FileData]] object.}} | + | {{#set:Description=Creates a new [[FileData]] object from a file on disk, or from a string in memory.}} |
{{#set:Since=070}} | {{#set:Since=070}} | ||
{{#set:PrettySince=0.7.0}} | {{#set:PrettySince=0.7.0}} | ||
== Other Languages == | == Other Languages == | ||
{{i18n|love.filesystem.newFileData}} | {{i18n|love.filesystem.newFileData}} |
Latest revision as of 17:24, 30 December 2021
Creates a new FileData object from a file on disk, or from a string in memory.
Contents
Function
Creates a new FileData object from a string in memory.
Synopsis
data = love.filesystem.newFileData( contents, name )
Arguments
string contents
- The contents of the file in memory represented as a string.
string name
- The name of the file. The extension may be parsed and used by LÖVE when passing the FileData object into love.audio.newSource.
Returns
FileData data
- The new FileData.
Function
Available since LÖVE 11.4 |
This variant is not supported in earlier versions. |
Creates a new FileData object from a Data object in memory.
Synopsis
data = love.filesystem.newFileData( originaldata, name )
Arguments
Data originaldata
- The Data object to copy into the new FileData object.
string name
- The name of the file. The extension may be parsed and used by LÖVE when passing the FileData object into love.audio.newSource.
Returns
FileData data
- The new FileData.
Function
Available since LÖVE 0.9.0 |
This variant is not supported in earlier versions. |
Creates a new FileData from a file on the storage device.
Synopsis
data, err = love.filesystem.newFileData( filepath )
Arguments
string filepath
- Path to the file.
Returns
FileData data
- The new FileData, or nil if an error occurred.
string err
- The error string, if an error occurred.
Function
Removed in LÖVE 11.0 |
The variant which decodes base64 data has been replaced by love.data.decode. |
Synopsis
data = love.filesystem.newFileData( contents, name, decoder )
Arguments
string contents
- The contents of the file.
string name
- The name of the file.
FileDecoder decoder
- The method to use when decoding the contents.
Returns
FileData data
- Your new FileData.
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