Introduces xmkstemp()

This is a wrapper for mkstemp() that performs error checking and
calls die() when an error occur.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Luiz Fernando N. Capitulino 2007-08-14 16:44:53 -03:00 committed by Junio C Hamano
parent eef427a09c
commit f21a47b27c

View File

@ -303,6 +303,16 @@ static inline FILE *xfdopen(int fd, const char *mode)
return stream;
}
static inline int xmkstemp(char *template)
{
int fd;
fd = mkstemp(template);
if (fd < 0)
die("Unable to create temporary file: %s", strerror(errno));
return fd;
}
static inline size_t xsize_t(off_t len)
{
return (size_t)len;