annotate liboctave/system/oct-env.h @ 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
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
1 /*
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
2
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 Copyright (C) 1996-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27832
diff changeset
4
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27832
diff changeset
5 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: 27832
diff changeset
6 or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27832
diff changeset
7
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
8
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
9 This file is part of Octave.
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
10
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
11 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 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: 23795
diff changeset
13 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 (at your option) any later version.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
15
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
19 GNU General Public License for more details.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
20
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
21 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: 6838
diff changeset
22 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: 23795
diff changeset
23 <https://www.gnu.org/licenses/>.
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
24
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
25 */
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
26
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
27 #if ! defined (octave_oct_env_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17744
diff changeset
28 #define octave_oct_env_h 1
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
29
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
30 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
31
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
21734
11af9c03400c write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
34 namespace octave
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
35 {
21734
11af9c03400c write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
36 namespace sys
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
37 {
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
38 class
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
39 OCTAVE_API
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
40 env
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
41 {
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
42 protected:
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
43
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
44 env (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
45
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
46 public:
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
47
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
48 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
49
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
50 env (const env&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
51
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
52 env& operator = (const env&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
53
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
54 static std::string polite_directory_format (const std::string& name);
6838
5e3350bdd91d [project @ 2007-08-28 02:59:58 by jwe]
jwe
parents: 6108
diff changeset
55
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
56 static bool absolute_pathname (const std::string& s);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
57
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
58 static bool rooted_relative_pathname (const std::string& s);
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
59
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
60 static std::string base_pathname (const std::string& s);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
61
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
62 static std::string
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
63 make_absolute (const std::string& s,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
64 const std::string& dot_path = get_current_directory ());
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
65
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
66 static std::string get_current_directory (void);
19458
d8fd3842a507 Use gnulib gen_tempname to create temporary names (Bug #43872).
John Donoghue <john.donoghue@ieee.org>
parents: 17822
diff changeset
67
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
68 static std::string get_home_directory (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
69
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
70 static std::string get_temp_directory (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
71
27832
8fd7d1d2a4ca Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
72 static std::string get_user_config_directory (void);
8fd7d1d2a4ca Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
73
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
74 static std::string get_program_name (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
75
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
76 static std::string get_program_invocation_name (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
77
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
78 static std::string get_user_name (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
79
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
80 static std::string get_host_name (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
81
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
82 static std::string getenv (const std::string& name);
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
83
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
84 static void putenv (const std::string& name, const std::string& value);
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5307
diff changeset
85
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
86 static bool have_x11_display (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
87
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
88 static bool chdir (const std::string& newdir);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
89
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
90 static void set_program_name (const std::string& s);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
91
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
92 private:
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
93
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
94 static bool instance_ok (void);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
95
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
96 std::string do_polite_directory_format (const std::string& name) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
97
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
98 bool do_absolute_pathname (const std::string& s) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
99
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
100 bool do_rooted_relative_pathname (const std::string& s) const;
6838
5e3350bdd91d [project @ 2007-08-28 02:59:58 by jwe]
jwe
parents: 6108
diff changeset
101
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
102 std::string do_base_pathname (const std::string& s) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
103
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
104 std::string do_make_absolute (const std::string& s,
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
105 const std::string& dot_path) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
106
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
107 std::string do_getcwd (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
108
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
109 std::string do_get_home_directory (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
110
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
111 std::string do_get_temp_directory (void) const;
19458
d8fd3842a507 Use gnulib gen_tempname to create temporary names (Bug #43872).
John Donoghue <john.donoghue@ieee.org>
parents: 17822
diff changeset
112
27832
8fd7d1d2a4ca Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
113 std::string do_get_user_config_directory (void) const;
8fd7d1d2a4ca Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
114
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
115 std::string do_get_user_name (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
116
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
117 std::string do_get_host_name (void) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
118
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
119 std::string do_getenv (const std::string& name) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
120
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
121 void do_putenv (const std::string& name, const std::string& value) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
122
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
123 bool do_chdir (const std::string& newdir);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
124
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
125 void do_set_program_name (const std::string& s) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
126
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
127 void pathname_backup (std::string& path, int n) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
128
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
129 void error (int) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
130
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
131 void error (const std::string&) const;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
132
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
133 // The real thing.
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
134 static env *instance;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
135
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23615
diff changeset
136 static void cleanup_instance (void) { delete instance; instance = nullptr; }
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
137
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
138 // TRUE means follow symbolic links that point to directories just
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
139 // as if they are real directories.
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
140 bool follow_symbolic_links;
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
141
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
142 // TRUE means that pwd always give verbatim directory, regardless
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
143 // of symbolic link following.
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
144 bool verbatim_pwd;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
145
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
146 // Where are we?
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
147 mutable std::string current_directory;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
148
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
149 // Etc.
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
150 mutable std::string prog_name;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
151
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
152 mutable std::string prog_invocation_name;
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
153
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
154 mutable std::string user_name;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
155
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
156 mutable std::string host_name;
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
157 };
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
158 }
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
159 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
160
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents:
diff changeset
161 #endif