home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos/dos.h>
- #ifdef __GNUC__
- #include <inline/exec.h>
- #include <inline/dos.h>
- #endif
-
- static char namebuffer[34];
-
- char *tmpnam(char *s)
- { BPTR filelock;
- static unsigned long filecount=0;
- if(s==NULL)
- s=namebuffer;
- do /* generate a filename that doesn't exist */
- { sprintf(s,"T:tempfile_2_%p_%lu",FindTask(NULL),filecount++);
- filelock=Lock(s,ACCESS_WRITE);
- if(filelock!=0)
- UnLock(filelock);
- }while(filelock!=0||IoErr()==ERROR_OBJECT_IN_USE);
- return s;
- }
-