libredirect: add support for mkdtemp
This commit is contained in:
parent
2185a70fa4
commit
d38832ace0
@ -443,3 +443,19 @@ WRAPPER(int, mkostemps)(char *template, int suffixlen, int flags)
|
||||
return retval;
|
||||
}
|
||||
WRAPPER_DEF(mkostemps)
|
||||
|
||||
WRAPPER(char *, mkdtemp)(char *template)
|
||||
{
|
||||
char * (*mkdtemp_real) (char *template) = LOOKUP_REAL(mkdtemp);
|
||||
char buf[PATH_MAX];
|
||||
char * rewritten = rewrite_non_const(template, buf);
|
||||
char * retval = mkdtemp_real(rewritten);
|
||||
if (retval == NULL) {
|
||||
return retval;
|
||||
};
|
||||
if (rewritten != template) {
|
||||
copy_temp_wildcard(template, rewritten, 0);
|
||||
}
|
||||
return template;
|
||||
}
|
||||
WRAPPER_DEF(mkdtemp)
|
||||
|
@ -117,6 +117,10 @@ int main(int argc, char *argv[])
|
||||
assert_mktemp_path(TESTDIR "/temp", ".test", buf);
|
||||
close(testfd);
|
||||
|
||||
strncpy(buf, TESTDIR "/tempXXXXXX", PATH_MAX);
|
||||
assert(mkdtemp(buf) == buf);
|
||||
assert_mktemp_path(TESTDIR "/temp", "", buf);
|
||||
|
||||
test_spawn();
|
||||
test_system();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user