Sign in
plan9port
/
plan9
/
0dc3aa4b1dcca64ca747de9ceb05f0033f884bd6
/
.
/
src
/
lib9
/
opentemp.c
blob: 9d4e2d077235c8b6f56a1d0c30837543c1dc6659 [
file
] [
log
] [
blame
]
#include
<u.h>
#include
<libc.h>
int
opentemp
(
char
*
template
,
int
mode
)
{
int
fd
,
fd1
;
fd
=
mkstemp
(
template
);
if
(
fd
<
0
)
return
-
1
;
if
((
fd1
=
open
(
template
,
mode
))
<
0
){
remove
(
template
);
close
(
fd
);
return
-
1
;
}
close
(
fd
);
return
fd1
;
}