2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
5 POSIX function mkstemp().
10 #include <proto/dos.h>
12 /*****************************************************************************
25 A template that must end with 'XXXXXX'
28 A file descriptor of opened temporary file or -1 on error.
40 ******************************************************************************/
42 char *c
= template + strlen(template);
46 static char filename_letters
[] = "01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZFILLTO64";
48 while (c
> template && *--c
== 'X') {
62 *c
= filename_letters
[rand() & 0x3F];
66 if (!(lock
= Lock(template, ACCESS_READ
))) {
67 int fd
= open(template, O_WRITE
|O_CREAT
|O_EXCL
);
74 * Try around 1000 filenames and then give up.