@matheusbsbs / matheus-bagliano / commits / f21a47b27c
Fork 0

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>

Luiz Fernando N. Capitulino committed Aug 14, 2007 at 16:44 UTC f21a47b27ceef8ff2f6f218d5b7266d5fd9e2e93
1 file changed +10
git-compat-util.h
+10
@@ -303,6 +303,16 @@ static inline FILE *xfdopen(int fd, const char *mode)
303 return stream;
304 }
305
306 +static inline int xmkstemp(char *template)
307 +{
308 + int fd;
309 +
310 + fd = mkstemp(template);
311 + if (fd < 0)
312 + die("Unable to create temporary file: %s", strerror(errno));
313 + return fd;
314 +}
315 +
316 static inline size_t xsize_t(off_t len)
317 {
318 return (size_t)len;