Difference between revisions of "Os.tmpname"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Class:''' [[os]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/os|os]]<br/>
 
=== <translate>Description</translate> ===
 
<translate>Returns a string with a file name that can be used for a temporary file. The file must be explicitly opened before its use and explicitly removed when no longer needed.
 
  
On some systems (POSIX), this function also creates a file with that name, to avoid security risks. (Someone else might create the file with wrong permissions in the time between getting the name and creating the file.) You still have to open the file to use it and to remove it (even if you do not use it).  
+
=== Description ===
 +
Returns a string with a file name that can be used for a temporary file. The file must be explicitly opened before its use and explicitly removed when no longer needed.
 +
<syntaxhighlight lang="lua">
 +
(string) = os.tmpname()
 +
</syntaxhighlight>
  
  When possible, you may prefer to use [[Special:MyLanguage/io.tmpfile|io.tmpfile]], which automatically removes the file when the program ends.</translate>
+
On some systems (POSIX), this function also creates a file with that name, to avoid security risks (someone else might create the file with wrong permissions in the time between getting the name and creating the file). You still have to open the file to use it and to remove it (even if you do not use it).
<source lang="lua">
+
 
(string) = os.tmpname()
+
  When possible, you may prefer to use [[io.tmpfile]], which automatically removes the file when the program ends.
</source>
+
 
=== <translate>Return values</translate> ===
+
=== Return values ===
'''<translate>Returns</translate>''' (string) <translate>name for the temporary file</translate><br/>
+
'''Returns''' (string) name for the temporary file<br/>
 +
 
 +
{{Os}}

Latest revision as of 14:32, 13 July 2023

Available since: Gideros 2011.6
Class: os

Description

Returns a string with a file name that can be used for a temporary file. The file must be explicitly opened before its use and explicitly removed when no longer needed.

(string) = os.tmpname()
On some systems (POSIX), this function also creates a file with that name, to avoid security risks (someone else might create the file with wrong permissions in the time between getting the name and creating the file). You still have to open the file to use it and to remove it (even if you do not use it).
When possible, you may prefer to use io.tmpfile, which automatically removes the file when the program ends.

Return values

Returns (string) name for the temporary file