From: Luiz Fernando N. Capitulino Date: Tue, 14 Aug 2007 19:44:53 +0000 (-0300) Subject: Introduces xmkstemp() X-Git-Tag: v1.5.3-rc5~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f21a47b27ceef8ff2f6f218d5b7266d5fd9e2e93;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/git-compat-util.h b/git-compat-util.h index 362e040f5..ca0a597a2 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -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;