GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
oct-env.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2026 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_oct_env_h)
27#define octave_oct_env_h 1
28
29#include "octave-config.h"
30
31#include <string>
32
35
37{
38protected:
39
40 env ();
41
42public:
43
44 OCTAVE_DISABLE_COPY_MOVE (env)
45
46 ~env () = default;
47
48 static std::string polite_directory_format (const std::string& name);
49
50 static bool absolute_pathname (const std::string& s);
51
52 static bool rooted_relative_pathname (const std::string& s);
53
54 static std::string base_pathname (const std::string& s);
55
56 static std::string
57 make_absolute (const std::string& s,
58 const std::string& dot_path = get_current_directory ());
59
60 static std::string get_current_directory ();
61
62 static std::string get_home_directory ();
63
64 static std::string get_temp_directory ();
65
66 static std::string get_user_config_directory ();
67
68 static std::string get_user_data_directory ();
69
70 static std::string get_program_name ();
71
72 static std::string get_program_invocation_name ();
73
74 static std::string get_user_name ();
75
76 static std::string get_host_name ();
77
78 static std::string getenv (const std::string& name);
79
80 static bool isenv (const std::string& name);
81
82 static void putenv (const std::string& name, const std::string& value);
83
84 static bool have_x11_display ();
85
86 static bool chdir (const std::string& newdir);
87
88 static void set_program_name (const std::string& s);
89
90private:
91
92 static bool instance_ok ();
93
94 std::string do_polite_directory_format (const std::string& name);
95
96 bool do_absolute_pathname (const std::string& s) const;
97
98 bool do_rooted_relative_pathname (const std::string& s) const;
99
100 std::string do_base_pathname (const std::string& s) const;
101
102 std::string do_make_absolute (const std::string& s,
103 const std::string& dot_path) const;
104
105 std::string do_getcwd ();
106
107 std::string do_get_home_directory ();
108
109 std::string do_get_temp_directory () const;
110
111 std::string do_get_user_config_directory ();
112
113 std::string do_get_user_data_directory ();
114
115 std::string do_get_user_name ();
116
117 std::string do_get_host_name ();
118
119 std::string do_getenv (const std::string& name) const;
120
121 void do_putenv (const std::string& name, const std::string& value) const;
122
123 bool do_chdir (const std::string& newdir);
124
125 void do_set_program_name (const std::string& s);
126
127 void pathname_backup (std::string& path, int n) const;
128
129 void error (int) const;
130
131 void error (const std::string&) const;
132
133 // The real thing.
134 static env *s_instance;
135
136 static void cleanup_instance ()
137 { delete s_instance; s_instance = nullptr; }
138
139 // TRUE means follow symbolic links that point to directories just
140 // as if they are real directories.
141 bool m_follow_symbolic_links;
142
143 // TRUE means that pwd always give verbatim directory, regardless
144 // of symbolic link following.
145 bool m_verbatim_pwd;
146
147 // Where are we?
148 std::string m_current_directory;
149
150 // Etc.
151 std::string m_prog_name;
152
153 std::string m_prog_invocation_name;
154
155 std::string m_user_name;
156
157 std::string m_host_name;
158};
159
160OCTAVE_END_NAMESPACE(sys)
161OCTAVE_END_NAMESPACE(octave)
162
163#endif
Definition oct-env.h:37
~env()=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error(const char *fmt,...)
Definition error.cc:1008
#define OCTAVE_API
Definition main.in.cc:55
int chdir(const std::string &path_arg)