GNU Octave 10.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-2025 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
34
36
38{
39protected:
40
41 env ();
42
43public:
44
45 OCTAVE_DISABLE_COPY_MOVE (env)
46
47 ~env () = default;
48
49 static std::string polite_directory_format (const std::string& name);
50
51 static bool absolute_pathname (const std::string& s);
52
53 static bool rooted_relative_pathname (const std::string& s);
54
55 static std::string base_pathname (const std::string& s);
56
57 static std::string
58 make_absolute (const std::string& s,
59 const std::string& dot_path = get_current_directory ());
60
61 static std::string get_current_directory ();
62
63 static std::string get_home_directory ();
64
65 static std::string get_temp_directory ();
66
67 static std::string get_user_config_directory ();
68
69 static std::string get_user_data_directory ();
70
71 static std::string get_program_name ();
72
73 static std::string get_program_invocation_name ();
74
75 static std::string get_user_name ();
76
77 static std::string get_host_name ();
78
79 static std::string getenv (const std::string& name);
80
81 static bool isenv (const std::string& name);
82
83 static void putenv (const std::string& name, const std::string& value);
84
85 static bool have_x11_display ();
86
87 static bool chdir (const std::string& newdir);
88
89 static void set_program_name (const std::string& s);
90
91private:
92
93 static bool instance_ok ();
94
95 std::string do_polite_directory_format (const std::string& name);
96
97 bool do_absolute_pathname (const std::string& s) const;
98
99 bool do_rooted_relative_pathname (const std::string& s) const;
100
101 std::string do_base_pathname (const std::string& s) const;
102
103 std::string do_make_absolute (const std::string& s,
104 const std::string& dot_path) const;
105
106 std::string do_getcwd ();
107
108 std::string do_get_home_directory ();
109
110 std::string do_get_temp_directory () const;
111
112 std::string do_get_user_config_directory ();
113
114 std::string do_get_user_data_directory ();
115
116 std::string do_get_user_name ();
117
118 std::string do_get_host_name ();
119
120 std::string do_getenv (const std::string& name) const;
121
122 void do_putenv (const std::string& name, const std::string& value) const;
123
124 bool do_chdir (const std::string& newdir);
125
126 void do_set_program_name (const std::string& s);
127
128 void pathname_backup (std::string& path, int n) const;
129
130 void error (int) const;
131
132 void error (const std::string&) const;
133
134 // The real thing.
135 static env *s_instance;
136
137 static void cleanup_instance ()
138 { delete s_instance; s_instance = nullptr; }
139
140 // TRUE means follow symbolic links that point to directories just
141 // as if they are real directories.
142 bool m_follow_symbolic_links;
143
144 // TRUE means that pwd always give verbatim directory, regardless
145 // of symbolic link following.
146 bool m_verbatim_pwd;
147
148 // Where are we?
149 std::string m_current_directory;
150
151 // Etc.
152 std::string m_prog_name;
153
154 std::string m_prog_invocation_name;
155
156 std::string m_user_name;
157
158 std::string m_host_name;
159};
160
161OCTAVE_END_NAMESPACE(sys)
162OCTAVE_END_NAMESPACE(octave)
163
164#endif
Definition oct-env.h:38
~env()=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error(const char *fmt,...)
Definition error.cc:1003
int chdir(const std::string &path_arg)
Definition lo-sysdep.cc:107
#define OCTAVE_API
Definition main.in.cc:55