Skip to content

Commit

Permalink
Introduces xmkstemp()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Luiz Fernando N. Capitulino authored and Junio C Hamano committed Aug 15, 2007
1 parent eef427a commit f21a47b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f21a47b

Please sign in to comment.