aboutsummaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>2007-08-14 16:44:53 -0300
committerJunio C Hamano <gitster@pobox.com>2007-08-14 22:20:23 -0700
commitf21a47b27ceef8ff2f6f218d5b7266d5fd9e2e93 (patch)
tree9a4b19955bde9fd32a2decc43bdeb9e3b69bdd69 /git-compat-util.h
parenteef427a09ce7fcbdc54c73ae363cbab331eccd88 (diff)
downloadgit-f21a47b27ceef8ff2f6f218d5b7266d5fd9e2e93.tar.gz
git-f21a47b27ceef8ff2f6f218d5b7266d5fd9e2e93.tar.xz
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>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h10
1 files changed, 10 insertions, 0 deletions
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;