GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-env.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_oct_env_h)
24 #define octave_oct_env_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 namespace octave
31 {
32  namespace sys
33  {
34  class
35  OCTAVE_API
36  env
37  {
38  protected:
39 
40  env (void);
41 
42  public:
43 
44  // No copying!
45 
46  env (const env&) = delete;
47 
48  env& operator = (const env&) = delete;
49 
50  static std::string polite_directory_format (const std::string& name);
51 
52  static bool absolute_pathname (const std::string& s);
53 
54  static bool rooted_relative_pathname (const std::string& s);
55 
56  static std::string base_pathname (const std::string& s);
57 
58  static std::string
59  make_absolute (const std::string& s,
60  const std::string& dot_path = get_current_directory ());
61 
62  static std::string get_current_directory (void);
63 
64  static std::string get_home_directory (void);
65 
66  static std::string get_temp_directory (void);
67 
68  static std::string get_program_name (void);
69 
70  static std::string get_program_invocation_name (void);
71 
72  static std::string get_user_name (void);
73 
74  static std::string get_host_name (void);
75 
76  static std::string getenv (const std::string& name);
77 
78  static void putenv (const std::string& name, const std::string& value);
79 
80  static bool have_x11_display (void);
81 
82  static bool chdir (const std::string& newdir);
83 
84  static void set_program_name (const std::string& s);
85 
86  private:
87 
88  static bool instance_ok (void);
89 
90  std::string do_polite_directory_format (const std::string& name) const;
91 
92  bool do_absolute_pathname (const std::string& s) const;
93 
94  bool do_rooted_relative_pathname (const std::string& s) const;
95 
96  std::string do_base_pathname (const std::string& s) const;
97 
98  std::string do_make_absolute (const std::string& s,
99  const std::string& dot_path) const;
100 
101  std::string do_getcwd (void) const;
102 
103  std::string do_get_home_directory (void) const;
104 
105  std::string do_get_temp_directory (void) const;
106 
107  std::string do_get_user_name (void) const;
108 
109  std::string do_get_host_name (void) const;
110 
111  std::string do_getenv (const std::string& name) const;
112 
113  void do_putenv (const std::string& name, const std::string& value) const;
114 
115  bool do_chdir (const std::string& newdir);
116 
117  void do_set_program_name (const std::string& s) const;
118 
119  void pathname_backup (std::string& path, int n) const;
120 
121  void error (int) const;
122 
123  void error (const std::string&) const;
124 
125  // The real thing.
126  static env *instance;
127 
128  static void cleanup_instance (void) { delete instance; instance = nullptr; }
129 
130  // TRUE means follow symbolic links that point to directories just
131  // as if they are real directories.
133 
134  // TRUE means that pwd always give verbatim directory, regardless
135  // of symbolic link following.
137 
138  // Where are we?
140 
141  // Etc.
143 
145 
147 
149  };
150  }
151 }
152 
153 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
154 
155 OCTAVE_DEPRECATED (4.2, "use 'octave::sys::env' instead")
156 typedef octave::sys::env octave_env;
157 
158 #endif
159 
160 #endif
static string_vector make_absolute(const string_vector &sv)
Definition: utils.cc:272
std::string current_directory
Definition: oct-env.h:139
void error(const char *fmt,...)
Definition: error.cc:578
s
Definition: file-io.cc:2729
bool follow_symbolic_links
Definition: oct-env.h:132
std::string host_name
Definition: oct-env.h:148
nd deftypefn *std::string name
Definition: sysdep.cc:647
static env * instance
Definition: oct-env.h:126
static bool absolute_pathname(const std::string &s)
Definition: shared-fcns.h:139
static void cleanup_instance(void)
Definition: oct-env.h:128
std::string prog_name
Definition: oct-env.h:142
std::string user_name
Definition: oct-env.h:146
std::string prog_invocation_name
Definition: oct-env.h:144
int chdir(const std::string &path_arg)
Definition: lo-sysdep.cc:59
bool verbatim_pwd
Definition: oct-env.h:136
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
nd group nd example For each display the value
Definition: sysdep.cc:866