annotate scripts/miscellaneous/tempdir.m @ 27919:1891570abac8

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2020.
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 22:29:51 -0500
parents b442ec6dda5c
children bd51beb6205e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
1 ## Copyright (C) 2003-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
2 ##
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ## or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
5 ##
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
6 ##
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
7 ## This file is part of Octave.
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
8 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
9 ## Octave is free software: you can redistribute it and/or modify it
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
10 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
11 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## (at your option) any later version.
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
13 ##
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
14 ## Octave is distributed in the hope that it will be useful, but
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## GNU General Public License for more details.
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
18 ##
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
19 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
20 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
21 ## <https://www.gnu.org/licenses/>.
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
22
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
23 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
24 ## @deftypefn {} {@var{dir} =} tempdir ()
19210
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
25 ## Return the name of the host system's directory for temporary files.
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
26 ##
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
27 ## The directory name is taken first from the environment variable
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
28 ## @env{TMPDIR}. If that does not exist the system default returned by
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
29 ## @code{P_tmpdir} is used.
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
30 ## @seealso{P_tmpdir, tempname, mkstemp, tmpfile}
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
31 ## @end deftypefn
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
32
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
33 function dirname = tempdir ()
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
34
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
35 dirname = getenv ("TMPDIR");
7430
8b7c7998d78f [project @ 2008-01-30 07:57:35 by jwe]
jwe
parents: 7017
diff changeset
36 if (isempty (dirname))
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
37 dirname = P_tmpdir;
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
38 endif
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
39
7430
8b7c7998d78f [project @ 2008-01-30 07:57:35 by jwe]
jwe
parents: 7017
diff changeset
40 if (! strcmp (dirname(end), filesep))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 15466
diff changeset
41 dirname = [dirname filesep];
7430
8b7c7998d78f [project @ 2008-01-30 07:57:35 by jwe]
jwe
parents: 7017
diff changeset
42 endif
8b7c7998d78f [project @ 2008-01-30 07:57:35 by jwe]
jwe
parents: 7017
diff changeset
43
25781
e04c56bbbace isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents: 25054
diff changeset
44 if (! isfolder (dirname))
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
45 warning ("tempdir: '%s' does not exist or is not a directory", dirname);
7430
8b7c7998d78f [project @ 2008-01-30 07:57:35 by jwe]
jwe
parents: 7017
diff changeset
46 endif
8b7c7998d78f [project @ 2008-01-30 07:57:35 by jwe]
jwe
parents: 7017
diff changeset
47
4266
1086ac09a411 [project @ 2003-01-03 06:22:54 by jwe]
jwe
parents:
diff changeset
48 endfunction
13072
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
49
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
50
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
51 %!assert (ischar (tempdir ()))
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
52
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
53 %!test
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
54 %! old_wstate = warning ("query");
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
55 %! warning ("off");
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
56 %! old_tmpdir = getenv ("TMPDIR");
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
57 %! unwind_protect
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
58 %! setenv ("TMPDIR", "__MY_TMP_DIR__");
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13072
diff changeset
59 %! assert (tempdir (), ["__MY_TMP_DIR__" filesep()]);
13072
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
60 %! unwind_protect_cleanup
19210
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
61 %! if (! isempty (old_tmpdir))
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
62 %! setenv ("TMPDIR", old_tmpdir);
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
63 %! else
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 %! unsetenv ("TMPDIR");
841d8f606bcd doc: Improve docstrings for tempname, tempdir family of functions.
Rik <rik@octave.org>
parents: 17744
diff changeset
65 %! endif
13072
39814ef3278b codesprint: Add tests for tempdir
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
66 %! warning (old_wstate);
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13072
diff changeset
67 %! end_unwind_protect