octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #62215] GUI tempfiles do not honor tmpdir envi


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #62215] GUI tempfiles do not honor tmpdir environment variable
Date: Sat, 2 Apr 2022 12:20:04 -0400 (EDT)

Follow-up Comment #8, bug #62215 (project octave):

That really is quite confusing:
We have `octave::env::get_temp_directory` that checks "TMP" but not "TMPDIR"
(the canonical environment variable for the temporary directory on POSIX)
before resorting to P_tmpdir (which is often just set to "/tmp" or "/var/tmp"
in <stdio.h> on Linux).
Then, we have the Octave function `tempdir` that checks "TMPDIR" but not "TMP"
(nor "TEMP" on Windows fwiw) before resorting to P_tmpdir.
Then, there is the Octave function `tempname` that manually checks "TMPDIR"
before passing on to `octave::env::tempnam` that hands off to
`octave::env::get_temp_directory`.
Then, there is the Octave function `tmpfile` that hands off to the gnulib
function `tmpfile` which I haven't checked what it does in which order.
Now, there is also a new function in libgui that does something similar. But
probably still different from any of the above.
And there are probably other functions that I have missed.

Maybe, it is time to consolidate all of this and merge them into one single
function that results in the same temporary directory in all of these cases.

Personally, I wouldn't bother adding in Qt as another source for a temporary
directory. If our "new and shiny" temp_directory function ends up with a
directory that can't be used, we are probably in deep trouble anyway... (But
that's just my 2 cents.)

Imho, we could probably add a check for "TMPDIR" as the first step in
`octave::sys::do_get_temp_directory` (on all platforms). Other than that, I'd
say it is the most complete one. The fallbacks on Windows and POSIX also look
reasonable to me. I'd guess that Qt will probably not do anything much fancier
either...

It also helps that `octave::env::get_temp_directory` is exported from
liboctave. It should be usable in all other Octave modules.

Then, we could retire the Octave function `tempdir` and replace it with a
DEFUN that just wraps around `octave::env::get_temp_directory`.
`tempname` already relies on the same function. It could probably drop the
check for "TMPDIR" if we move that some levels deeper.
We could probably also unify the implementations of `tempname` and `tmpfile`
and retire the gnulib wrapper...
After that, at least those functions should use a consistent temporary
directory. And that updated function could probably also be used in libgui.

What do you think?



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62215>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]