2 Copyright © 2010-2013, The AROS Development Team. All rights reserved.
6 This function is based on the public domain libnix code
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <aros/libcall.h>
15 #include "__stdcio_intbase.h"
17 /*****************************************************************************
28 The tmpnam function generates a string that is a valid file name and
29 that is not the same as the name of an existing file. The function
30 is potentially capable of generating TMP_MAX different strings, but
31 any or all of them may already be in use by existing files and thus
32 not be suitable return values.
35 Pointer to a string of at least L_tmpnam characters.
38 The resulting file name is returned in the input string pointer
39 or a pointer to an internal buffer if NULL was passed to the function.
40 If file name generation failed a NULL is returned.
53 ******************************************************************************/
55 struct StdCIOIntBase
*StdCIOBase
=
56 (struct StdCIOIntBase
*)__aros_getbase_StdCIOBase();
59 s
= StdCIOBase
->tmpnambuffer
;
61 do /* generate a filename that doesn't exist */
63 sprintf(s
,"T:tempfile_stdc_%p_%lu",FindTask(NULL
),StdCIOBase
->filecount
++);
64 filelock
= Lock(s
,ACCESS_WRITE
);
67 } while(filelock
!=0 || IoErr()==ERROR_OBJECT_IN_USE
);