aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/opentemp.c
diff options
context:
space:
mode:
authorMichael Teichgräber <devnull@localhost>2008-07-09 08:27:22 -0400
committerMichael Teichgräber <devnull@localhost>2008-07-09 08:27:22 -0400
commitf35a04866f298aa4b0fa6846da0c0187751ce9b2 (patch)
treeaa4b87fbc1f71b246c9c8975abb0cab936f7ef2b /src/lib9/opentemp.c
parent1cccddd6b3fb4a90641b8d05dc0bed618380074c (diff)
downloadplan9port-f35a04866f298aa4b0fa6846da0c0187751ce9b2.tar.gz
plan9port-f35a04866f298aa4b0fa6846da0c0187751ce9b2.tar.bz2
plan9port-f35a04866f298aa4b0fa6846da0c0187751ce9b2.zip
lib9: rewrite date routines to use /usr/share/zoneinfo directly
Diffstat (limited to 'src/lib9/opentemp.c')
-rw-r--r--src/lib9/opentemp.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib9/opentemp.c b/src/lib9/opentemp.c
index f90bf771..0af154de 100644
--- a/src/lib9/opentemp.c
+++ b/src/lib9/opentemp.c
@@ -2,14 +2,20 @@
#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;
+ /* reopen for mode */
+ fd1 = open(template, mode);
+ if(fd1 < 0){
+ close(fd);
+ remove(template);
+ return -1;
+ }
+ close(fd);
+ return fd1;
}
-