2004-03-21 14:05:38 +00:00
|
|
|
#include <u.h>
|
|
|
|
|
#include <libc.h>
|
|
|
|
|
|
|
|
|
|
int
|
2008-07-10 11:10:10 -04:00
|
|
|
opentemp(char *template, int mode)
|
2004-03-21 14:05:38 +00:00
|
|
|
{
|
2008-07-10 11:10:10 -04:00
|
|
|
int fd, fd1;
|
2004-06-17 21:19:37 +00:00
|
|
|
|
|
|
|
|
fd = mkstemp(template);
|
|
|
|
|
if(fd < 0)
|
|
|
|
|
return -1;
|
2008-07-10 11:10:10 -04:00
|
|
|
if((fd1 = open(template, mode)) < 0){
|
|
|
|
|
remove(template);
|
|
|
|
|
close(fd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
close(fd);
|
|
|
|
|
return fd1;
|
2004-03-21 14:05:38 +00:00
|
|
|
}
|
2008-07-09 11:53:31 -04:00
|
|
|
|