]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Introduces xmkstemp()
authorLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Tue, 14 Aug 2007 19:44:53 +0000 (16:44 -0300)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Aug 2007 05:20:23 +0000 (22:20 -0700)
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>
git-compat-util.h

index 362e040f52cf8df17811ae95e46f0b60d2b6f071..ca0a597a282328bff9e0e29fd3653dbd656489fb 100644 (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;