lib9: add mode parameter to opentemp

This commit is contained in:
Russ Cox 2008-07-10 11:10:10 -04:00
parent c224dda84e
commit a58a827f2a
9 changed files with 23 additions and 34 deletions

View file

@ -2,14 +2,19 @@
#include <libc.h>
int
opentemp(char *template)
opentemp(char *template, int mode)
{
int fd;
int fd, fd1;
fd = mkstemp(template);
if(fd < 0)
return -1;
remove(template);
return fd;
if((fd1 = open(template, mode)) < 0){
remove(template);
close(fd);
return -1;
}
close(fd);
return fd1;
}