freebsd-ports/devel/kdesvn/files/patch-src-svnqt-path.cpp
Cheng-Lung Sung fefe2fb57a - I forgot to add two new patch into repo.
PR:		ports/104196
Submitted by:	maintainer (Yuan Jue)
2006-10-09 16:50:28 +00:00

108 lines
3.4 KiB
C++

--- src/svnqt/path.cpp.orig Tue Sep 26 05:32:24 2006
+++ src/svnqt/path.cpp Mon Oct 9 00:05:26 2006
@@ -186,105 +186,6 @@
}
}
- /* ===================================================================
- * The next two Fixed_* functions are copies of the APR
- * apr_temp_dir_get functionality with a fix applied.
- * This should turn up in APR release 0.9.5 or 1.0, but
- * for now is reproduced here.
- *
- * TODO: Remove this section!
- */
-#include "apr_env.h"
-
-#define test_tempdir Fixed_test_tempdir
-#define apr_temp_dir_get Fixed_apr_temp_dir_get
-
- static char global_temp_dir[APR_PATH_MAX+1] = { 0 };
-
- /* Try to open a temporary file in the temporary dir, write to it,
- and then close it. */
- static int Fixed_test_tempdir(const char *temp_dir, apr_pool_t *p)
- {
- apr_file_t *dummy_file;
- // This is the only actual fix - adding the ".XXXXXX"!
- const char *path = apr_pstrcat(p, temp_dir, "/apr-tmp.XXXXXX", NULL);
-
- if (apr_file_mktemp(&dummy_file, (char *)path, 0, p) == APR_SUCCESS) {
- if (apr_file_putc('!', dummy_file) == APR_SUCCESS) {
- if (apr_file_close(dummy_file) == APR_SUCCESS) {
- apr_file_remove(path, p);
- return 1;
- }
- }
- }
- return 0;
- }
-
- static apr_status_t Fixed_apr_temp_dir_get(const char **temp_dir, apr_pool_t *p)
- {
- apr_status_t apr_err;
- const char *try_dirs[] = { "/tmp", "/usr/tmp", "/var/tmp" };
- const char *try_envs[] = { "TMP", "TEMP", "TMPDIR" };
- char *cwd;
- size_t i;
-
- /* Our goal is to find a temporary directory suitable for writing
- into. We'll only pay the price once if we're successful -- we
- cache our successful find. Here's the order in which we'll try
- various paths:
-
- $TMP
- $TEMP
- $TMPDIR
- "/tmp"
- "/var/tmp"
- "/usr/tmp"
- `pwd`
-
- NOTE: This algorithm is basically the same one used by Python
- 2.2's tempfile.py module. */
-
- /* Try the environment first. */
- for (i = 0; i < (sizeof(try_envs) / sizeof(const char *)); i++) {
- char *value;
- apr_err = apr_env_get(&value, try_envs[i], p);
- if ((apr_err == APR_SUCCESS) && value) {
- apr_size_t len = strlen(value);
- if (len && (len < APR_PATH_MAX) && test_tempdir(value, p)) {
- memcpy(global_temp_dir, value, len + 1);
- goto end;
- }
- }
- }
-
- /* Next, try a set of hard-coded paths. */
- for (i = 0; i < (sizeof(try_dirs) / sizeof(const char *)); i++) {
- if (test_tempdir(try_dirs[i], p)) {
- memcpy(global_temp_dir, try_dirs[i], strlen(try_dirs[i]) + 1);
- goto end;
- }
- }
-
- /* Finally, try the current working directory. */
- if (APR_SUCCESS == apr_filepath_get(&cwd, APR_FILEPATH_NATIVE, p)) {
- if (test_tempdir(cwd, p)) {
- memcpy(global_temp_dir, cwd, strlen(cwd) + 1);
- goto end;
- }
- }
-
-end:
- if (global_temp_dir[0]) {
- *temp_dir = apr_pstrdup(p, global_temp_dir);
- return APR_SUCCESS;
- }
- return APR_EGENERAL;
- }
-
- /* ===================================================================
- * End of inserted fixed APR code
- */
-
Path
Path::getTempDir ()
{