diff options
| author | Junio C Hamano <gitster@pobox.com> | 2009-06-03 00:50:05 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2009-06-03 00:50:05 -0700 |
| commit | b11cf09043f18b368ec0d988f064ea21247c843d (patch) | |
| tree | 864a5086870ab9f5e48b3f6e2d5fa1264e9f074a /path.c | |
| parent | ceff8e7adeed51024491deb4933f23db760e5641 (diff) | |
| parent | 003b33a8ad686ee4a0d0b36635bfd6aba940b24a (diff) | |
| download | git-b11cf09043f18b368ec0d988f064ea21247c843d.tar.gz | |
Merge branch 'da/pretty-tempname'
* da/pretty-tempname:
diff: generate pretty filenames in prep_temp_blob()
compat: add a basename() compatibility function
compat: add a mkstemps() compatibility function
Conflicts:
Makefile
Diffstat (limited to 'path.c')
| -rw-r--r-- | path.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -139,6 +139,22 @@ int git_mkstemp(char *path, size_t len, const char *template) return mkstemp(path); } +/* git_mkstemps() - create tmp file with suffix honoring TMPDIR variable. */ +int git_mkstemps(char *path, size_t len, const char *template, int suffix_len) +{ + const char *tmp; + size_t n; + + tmp = getenv("TMPDIR"); + if (!tmp) + tmp = "/tmp"; + n = snprintf(path, len, "%s/%s", tmp, template); + if (len <= n) { + errno = ENAMETOOLONG; + return -1; + } + return mkstemps(path, suffix_len); +} int validate_headref(const char *path) { |
