annotate liboctave/system/lo-sysdep.h @ 30881:1921d9d0e62b

Unify detection of temporary directory (bug #62215). Instead of using differing implementations of detecting the temporary directory in multiple functions, use "sys::env::get_temp_directory" (in some of them). * libinterp/corefcn/file-io.cc (Ftempdir): Add implementation wrapping around "sys::env::get_temp_directory" replacing tempdir.m. (Ftempname): Remove local check of environment variable "TMPDIR". (Ftmpfile): Create temporary file in directory given by "sys::env::get_temp_directory". * libinterp/corefcn/gl2ps-print.cc (gl2ps_renderer::draw): Use Octave's functions for opening temporary file. * liboctave/system/oct-env.cc (sys::env::do_get_temp_directory): Check environment variable "TMPDIR" on all platforms. * liboctave/system/lo-sysdep.h, lo-sysdep.cc (sys::fopen_tmp): Add new function to open temporary file that deletes automatically after use. * scripts/miscellaneous/tempdir.m: Remove file that is replaced by DEFUN. * scripts/miscellaneous/module.mk: Remove deleted file from list. * bootstrap.conf, liboctave/wrappers/tmpfile-wrapper.h, tmpfile-wrapper.c, liboctave/wrappers/module.mk: Remove unused module "tmpfile".
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 03 Apr 2022 12:38:19 +0200
parents 796f54d4ddbf
children e88a07dec498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_lo_sysdep_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17769
diff changeset
27 #define octave_lo_sysdep_h 1
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
30
28467
159b6a1eb408 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
31 #include <fstream>
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
32 #include <string>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
33
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21828
diff changeset
34 #include <sys/types.h>
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21828
diff changeset
35
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
36 #include "lo-ieee.h"
21738
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
37
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 6123
diff changeset
38 class string_vector;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
39
21738
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
40 namespace octave
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
41 {
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
42 namespace sys
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
43 {
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
44 extern OCTAVE_API int system (const std::string& cmd_str);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
45
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
46 extern OCTAVE_API std::string getcwd (void);
25514
c63f67d87b4a Add C++ functions to convert between UTF-8 string and wstring (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25147
diff changeset
47
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
48 extern OCTAVE_API int chdir (const std::string&);
25516
8945a6a6c0eb Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25514
diff changeset
49
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
50 extern OCTAVE_API bool
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
51 get_dirlist (const std::string& dirname, string_vector& dirlist,
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
52 std::string& msg);
25517
7fbc39a46be8 Add wrapper to fopen for files with non-ASCII chars in path on Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25516
diff changeset
53
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
54 extern OCTAVE_API std::FILE *
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
55 fopen (const std::string& name, const std::string& mode);
28467
159b6a1eb408 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
56
30881
1921d9d0e62b Unify detection of temporary directory (bug #62215).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
57 extern OCTAVE_API std::FILE *
1921d9d0e62b Unify detection of temporary directory (bug #62215).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
58 fopen_tmp (const std::string& name, const std::string& mode);
1921d9d0e62b Unify detection of temporary directory (bug #62215).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
59
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
60 extern OCTAVE_API std::fstream
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
61 fstream (const std::string& name,
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
62 const std::ios::openmode mode = std::ios::in | std::ios::out);
28467
159b6a1eb408 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
63
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
64 extern OCTAVE_API std::ifstream
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
65 ifstream (const std::string& name,
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
66 const std::ios::openmode mode = std::ios::in);
28467
159b6a1eb408 Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
67
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
68 extern OCTAVE_API std::ofstream
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
69 ofstream (const std::string& name,
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
70 const std::ios::openmode mode = std::ios::out);
25916
3f2282954600 Support non-ASCII characters in environment variables on Windows (bug #53922).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25532
diff changeset
71
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
72 extern OCTAVE_API void
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
73 putenv_wrapper (const std::string& name, const std::string& value);
25916
3f2282954600 Support non-ASCII characters in environment variables on Windows (bug #53922).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25532
diff changeset
74
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
75 extern OCTAVE_API std::string getenv_wrapper (const std::string&);
25916
3f2282954600 Support non-ASCII characters in environment variables on Windows (bug #53922).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25532
diff changeset
76
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
77 extern OCTAVE_API int unsetenv_wrapper (const std::string&);
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
78
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
79 extern OCTAVE_API std::wstring u8_to_wstring (const std::string&);
25514
c63f67d87b4a Add C++ functions to convert between UTF-8 string and wstring (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25147
diff changeset
80
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
81 extern OCTAVE_API std::string u8_from_wstring (const std::wstring&);
25532
7dad5fa7e88e Add function for ASCII only file names (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25517
diff changeset
82
29229
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
83 extern OCTAVE_API std::string
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
84 get_ASCII_filename (const std::string& long_file_name,
ed5eacd5c3ed Set API tags in files in liboctave/system (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29141
diff changeset
85 const bool allow_locale = false);
21738
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
86 }
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
87 }
a99c2407f930 use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
88
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 6123
diff changeset
89 #endif