Mercurial > hg > octave-shane
changeset 12308:b6e47a4de018 release-3-4-x
try to get better value than \ for P_tmpdir on Windows systems
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 31 Jan 2011 03:19:01 -0500 |
parents | 3dc4cfc5a3c1 |
children | 7c6c84f6b7e4 |
files | src/ChangeLog src/file-io.cc src/sysdep.cc src/sysdep.h |
diffstat | 4 files changed, 48 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-01-31 John W. Eaton <jwe@octave.org> + + * sysdep.cc (get_P_tmpdir): New function. + * file-io.cc (FP_tmpdir): Use it. + Bug #32158. + 2011-01-30 Rik <octave@nomad.inbox5.com> * DLD-FUNCTIONS/__init_fltk__.cc (mouse_wheel_zoom, gui_mode): Rename
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -2125,10 +2125,6 @@ return retval; } -#if ! defined (P_tmpdir) -#define P_tmpdir "/tmp" -#endif - DEFUNX ("P_tmpdir", FP_tmpdir, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} P_tmpdir ()\n\ @@ -2141,7 +2137,7 @@ int nargin = args.length (); if (nargin == 0) - retval = P_tmpdir; + retval = get_P_tmpdir (); else print_usage ();
--- a/src/sysdep.cc +++ b/src/sysdep.cc @@ -470,6 +470,45 @@ return c; } +std::string +get_P_tmpdir (void) +{ +#if defined (__WIN32__) && ! defined (_POSIX_VERSION) + + std::string retval; + +#if defined (P_tmpdir) + retval = P_tmpdir; +#endif + + // Apparently some versions of MinGW and MSVC either don't define + // P_tmpdir, or they define it to a single backslash, neither of which + // is particularly helpful. + + if (retval.empty () || retval == "\\") + { + retval = octave_env::getenv ("TEMP"); + + if (retval.empty ()) + retval = octave_env::getenv ("TMP"); + + if (retval.empty ()) + retval = "c:\\temp"; + } + + return retval; + +#elif defined (P_tmpdir) + + return P_tmpdir; + +#else + + return "/tmp"; + +#endif +} + DEFUN (clc, , , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} clc ()\n\