From 5095c3880cd386864accbdafd63fef3b442448e9 Mon Sep 17 00:00:00 2001 From: Bradley Nicholes Date: Wed, 17 Mar 2004 00:04:35 +0000 Subject: [PATCH] Use apr_temp_dir_get() to get the temporary directory Submitted by: Guenter Knauf git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102998 13f79535-47bb-0310-9956-ffa450edef68 --- support/htdigest.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/support/htdigest.c b/support/htdigest.c index e0801b1687..56917d5928 100644 --- a/support/htdigest.c +++ b/support/htdigest.c @@ -208,6 +208,7 @@ int main(int argc, const char * const argv[]) apr_file_t *f; apr_status_t rv; char tn[] = "htdigest.tmp.XXXXXX"; + char *dirname; char user[MAX_STRING_LEN]; char realm[MAX_STRING_LEN]; char line[MAX_STRING_LEN]; @@ -251,7 +252,14 @@ int main(int argc, const char * const argv[]) else if (argc != 4) usage(); - if (apr_file_mktemp(&tfp, tn, + if (apr_temp_dir_get((const char**)&dirname, cntxt) != APR_SUCCESS) { + fprintf(stderr, "%s: could not determine temp dir\n", + argv[0]); + exit(1); + } + dirname = apr_psprintf(cntxt, "%s/%s", dirname, tn); + + if (apr_file_mktemp(&tfp, dirname, #ifdef OMIT_DELONCLOSE APR_CREATE | APR_READ | APR_WRITE | APR_EXCL #else @@ -296,15 +304,15 @@ int main(int argc, const char * const argv[]) } apr_file_close(f); #if defined(OS2) || defined(WIN32) - sprintf(command, "copy \"%s\" \"%s\"", tn, argv[1]); + sprintf(command, "copy \"%s\" \"%s\"", dirname, argv[1]); #else - sprintf(command, "cp %s %s", tn, argv[1]); + sprintf(command, "cp %s %s", dirname, argv[1]); #endif #ifdef OMIT_DELONCLOSE apr_file_close(tfp); system(command); - apr_file_remove(tn, cntxt); + apr_file_remove(dirname, cntxt); #else system(command); apr_file_close(tfp); -- 2.50.1