| tempnam |
(String dir, String prefix [, String suffix]) |
yoix.stdio |
| |
Returns the name of a file that does not currently exist in directory
dir
if it is not
NULL,
or
VM.tmpdir,
otherwise.
prefix,
when not
NULL,
is prepended to the last component of the generated file name and
can be used to generate application specific temporary files.
Similarly, when
suffix
is present and not
NULL,
it is appended to the last component of the generated file name and
can be used to generate filetype specific temporary files.
tempnam
gives up after a large number of attempts (currently 456976),
and returns
NULL
to indicate failure.
tempnam
remembers the last generated name, so the next call gets a new one
even if the previous file has not been created.
Names are eventually recycled, but there are lots of choices so
collisions are usually not a problem.
| |
| Example: |
On a UNIX-like system the program,
import yoix.stdio.*;
printf("name1=%s\n", tempnam(NULL, NULL));
printf("name2=%s\n", tempnam(NULL, NULL));
printf("name3=%s\n", tempnam("/var/tmp", NULL));
printf("name4=%s\n", tempnam("/var/tmp", "YOIX"));
prints something like
name1=/tmp/aaaabgIWc
name2=/tmp/baaabgIWc
name3=/var/tmp/caaabgIWc
name4=/var/tmp/YOIXdaaabgIWc
on standard output.
Notice that the first two names are different,
even though we did not create either file.
| | |
| Return: |
String
| | |
| See Also: |
mktemp,
tmpnam
|
|
Yoix is a registered trademark of AT&T Intellectual Property.
|