Sander Striker had an idea: it would be great it if people could
glance over
subversion/libsvn_subr/io.c:svn_io_temp_dir()
to see if the function misses any standard tmp dir locations... In
fact, to make it *really* easy, I'll just paste the whole function in
right here. Thanks, -Karl
svn_error_t *
svn_io_temp_dir (const char **dir,
apr_pool_t *pool)
{
#if 1 /* TODO: Remove this code when APR 0.9.6 is released. */
apr_status_t apr_err;
static const char *try_dirs[] = { "/tmp", "/usr/tmp", "/var/tmp" };
static const char *try_envs[] = { "TMP", "TEMP", "TMPDIR" };
const char *temp_dir;
char *cwd;
apr_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
"C:\TEMP" (windows only)
"/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], pool);
if ((apr_err == APR_SUCCESS) && value)
{
apr_size_t len = strlen(value);
if (len && (len < APR_PATH_MAX) && test_tempdir(value, pool))
{
temp_dir = value;
goto end;
}
}
}
#ifdef SVN_WIN32
/* Next, on Win32, try the C:\TEMP directory. */
if (test_tempdir("C:\\TEMP", pool))
{
temp_dir = "C:\\TEMP";
goto end;
}
#endif /* SVN_WIN32 */
/* 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], pool))
{
temp_dir = try_dirs[i];
goto end;
}
}
/* Finally, try the current working directory. */
if (APR_SUCCESS == apr_filepath_get(&cwd, APR_FILEPATH_NATIVE, pool))
{
if (test_tempdir(cwd, pool))
{
temp_dir = cwd;
goto end;
}
}
return svn_error_create
(APR_EGENERAL, NULL,
"svn_io_temp_dir: Unable to find a suitable temporary directory");
end:
*dir = svn_path_canonicalize(temp_dir, pool);
return SVN_NO_ERROR;
#else
apr_status_t apr_err = apr_temp_dir_get (dir, pool);
if (apr_err)
return svn_error_create
(apr_err, NULL,
"svn_io_temp_dir: Unable to find a suitable temporary directory");
*dir = svn_path_canonicalize (*dir, pool);
return SVN_NO_ERROR;
#endif
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Nov 10 19:14:26 2003