mirror of
https://github.com/cahirwpz/libnix.git
synced 2026-09-11 19:26:17 +00:00
Moved headers around so we include <devices/timer.h> before <sys/time.h> (so we don't have to patch the OS headers)
32 lines
488 B
C
Executable File
32 lines
488 B
C
Executable File
#include <proto/exec.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
|
|
char *mktemp(char *buf)
|
|
{ long pid = (long)FindTask(0L);
|
|
char *c = buf;
|
|
|
|
while(*c++); --c;
|
|
|
|
while(*--c == 'X') {
|
|
*c = pid % 10 + '0';
|
|
pid /= 10;
|
|
}
|
|
|
|
if (++c,*c) {
|
|
for(*c='A'; *c <= 'Z'; (*c)++) {
|
|
if (access(buf,0)) {
|
|
return buf;
|
|
}
|
|
}
|
|
*c = 0;
|
|
}
|
|
|
|
return buf;
|
|
}
|
|
|
|
int mkstemp(char *template) {
|
|
char *buf = mktemp(template);
|
|
return open(buf, O_CREAT | O_TRUNC | O_EXCL);
|
|
}
|