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