[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Old Hundred Eyes review of svn_io_temp_dir requested

From: Kevin Pilch-Bisson <kevin_at_pilch-bisson.net>
Date: 2003-11-10 15:47:24 CET

C:\Temp is deprecated on Win32 in favour of per-user temp directories under
documents and settings. I'd love to see svn do that properly. It could never
get a designed for Windows XP logo otherwise :)

On Mon, Nov 10, 2003 at 11:32:55AM -0600, kfogel@collab.net wrote:
> 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
>

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Pilch-Bisson                    http://www.pilch-bisson.net
     "Historically speaking, the presences of wheels in Unix
     has never precluded their reinvention." - Larry Wall
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • application/pgp-signature attachment: stored
Received on Mon Nov 10 23:03:48 2003

This is an archived mail posted to the Subversion Dev mailing list.