libredirect: add support for mktemp
This commit is contained in:
parent
d38832ace0
commit
86783a69c2
2 changed files with 20 additions and 0 deletions
|
@ -459,3 +459,19 @@ WRAPPER(char *, mkdtemp)(char *template)
|
|||
return template;
|
||||
}
|
||||
WRAPPER_DEF(mkdtemp)
|
||||
|
||||
WRAPPER(char *, mktemp)(char *template)
|
||||
{
|
||||
char * (*mktemp_real) (char *template) = LOOKUP_REAL(mktemp);
|
||||
char buf[PATH_MAX];
|
||||
char * rewritten = rewrite_non_const(template, buf);
|
||||
char * retval = mktemp_real(rewritten);
|
||||
if (retval == NULL) {
|
||||
return retval;
|
||||
};
|
||||
if (rewritten != template) {
|
||||
copy_temp_wildcard(template, rewritten, 0);
|
||||
}
|
||||
return template;
|
||||
}
|
||||
WRAPPER_DEF(mktemp)
|
||||
|
|
|
@ -121,6 +121,10 @@ int main(int argc, char *argv[])
|
|||
assert(mkdtemp(buf) == buf);
|
||||
assert_mktemp_path(TESTDIR "/temp", "", buf);
|
||||
|
||||
strncpy(buf, TESTDIR "/tempXXXXXX", PATH_MAX);
|
||||
assert(mktemp(buf) == buf);
|
||||
assert_mktemp_path(TESTDIR "/temp", "", buf);
|
||||
|
||||
test_spawn();
|
||||
test_system();
|
||||
|
||||
|
|
Loading…
Reference in a new issue