Browse Source

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>
maint
Luiz Fernando N. Capitulino 18 years ago committed by Junio C Hamano
parent
commit
f21a47b27c
  1. 10
      git-compat-util.h

10
git-compat-util.h

@ -303,6 +303,16 @@ static inline FILE *xfdopen(int fd, const char *mode) @@ -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;

Loading…
Cancel
Save