GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-env.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_oct_env_h)
24 #define octave_oct_env_h 1
25 
26 #include <string>
27 
28 class
29 OCTAVE_API
31 {
32 protected:
33 
34  octave_env (void);
35 
36 public:
37 
38  static std::string polite_directory_format (const std::string& name);
39 
40  static bool absolute_pathname (const std::string& s);
41 
42  static bool rooted_relative_pathname (const std::string& s);
43 
44  static std::string base_pathname (const std::string& s);
45 
46  static std::string
47  make_absolute (const std::string& s,
48  const std::string& dot_path = get_current_directory ());
49 
50  static std::string get_current_directory (void);
51 
52  static std::string get_home_directory (void);
53 
54  static std::string get_temp_directory (void);
55 
56  static std::string get_program_name (void);
57 
58  static std::string get_program_invocation_name (void);
59 
60  static std::string get_user_name (void);
61 
62  static std::string get_host_name (void);
63 
64  static std::string getenv (const std::string& name);
65 
66  static void putenv (const std::string& name, const std::string& value);
67 
68  static bool have_x11_display (void);
69 
70  static bool chdir (const std::string& newdir);
71 
72  static void set_program_name (const std::string& s);
73 
74 private:
75 
76  static bool instance_ok (void);
77 
78  std::string do_polite_directory_format (const std::string& name) const;
79 
80  bool do_absolute_pathname (const std::string& s) const;
81 
82  bool do_rooted_relative_pathname (const std::string& s) const;
83 
84  std::string do_base_pathname (const std::string& s) const;
85 
86  std::string do_make_absolute (const std::string& s,
87  const std::string& dot_path) const;
88 
89  std::string do_getcwd (void) const;
90 
91  std::string do_get_home_directory (void) const;
92 
93  std::string do_get_temp_directory (void) const;
94 
95  std::string do_get_user_name (void) const;
96 
97  std::string do_get_host_name (void) const;
98 
99  std::string do_getenv (const std::string& name) const;
100 
101  void do_putenv (const std::string& name, const std::string& value) const;
102 
103  bool do_chdir (const std::string& newdir);
104 
105  void do_set_program_name (const std::string& s) const;
106 
107  void pathname_backup (std::string& path, int n) const;
108 
109  void error (int) const;
110 
111  void error (const std::string&) const;
112 
113  // No copying!
114 
115  octave_env (const octave_env&);
116 
117  octave_env& operator = (const octave_env&);
118 
119  // The real thing.
121 
122 
123  static void cleanup_instance (void) { delete instance; instance = 0; }
124 
125  // TRUE means follow symbolic links that point to directories just
126  // as if they are real directories.
128 
129  // TRUE means that pwd always give verbatim directory, regardless
130  // of symbolic link following.
132 
133  // Where are we?
134  mutable std::string current_directory;
135 
136  // Etc.
137  mutable std::string prog_name;
138 
139  mutable std::string prog_invocation_name;
140 
141  mutable std::string user_name;
142 
143  mutable std::string host_name;
144 };
145 
146 #endif
bool verbatim_pwd
Definition: oct-env.h:131
static string_vector make_absolute(const string_vector &sv)
Definition: utils.cc:279
void error(const char *fmt,...)
Definition: error.cc:476
static void cleanup_instance(void)
Definition: oct-env.h:123
std::string prog_invocation_name
Definition: oct-env.h:139
std::string prog_name
Definition: oct-env.h:137
std::string host_name
Definition: oct-env.h:143
std::string user_name
Definition: oct-env.h:141
bool follow_symbolic_links
Definition: oct-env.h:127
std::string current_directory
Definition: oct-env.h:134
static octave_env * instance
Definition: oct-env.h:120