GNU Octave  4.2.1
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-2017 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 "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  static std::string polite_directory_format (const std::string& name);
45 
46  static bool absolute_pathname (const std::string& s);
47 
48  static bool rooted_relative_pathname (const std::string& s);
49 
50  static std::string base_pathname (const std::string& s);
51 
52  static std::string
53  make_absolute (const std::string& s,
54  const std::string& dot_path = get_current_directory ());
55 
56  static std::string get_current_directory (void);
57 
58  static std::string get_home_directory (void);
59 
60  static std::string get_temp_directory (void);
61 
62  static std::string get_program_name (void);
63 
64  static std::string get_program_invocation_name (void);
65 
66  static std::string get_user_name (void);
67 
68  static std::string get_host_name (void);
69 
70  static std::string getenv (const std::string& name);
71 
72  static void putenv (const std::string& name, const std::string& value);
73 
74  static bool have_x11_display (void);
75 
76  static bool chdir (const std::string& newdir);
77 
78  static void set_program_name (const std::string& s);
79 
80  private:
81 
82  static bool instance_ok (void);
83 
84  std::string do_polite_directory_format (const std::string& name) const;
85 
86  bool do_absolute_pathname (const std::string& s) const;
87 
88  bool do_rooted_relative_pathname (const std::string& s) const;
89 
90  std::string do_base_pathname (const std::string& s) const;
91 
92  std::string do_make_absolute (const std::string& s,
93  const std::string& dot_path) const;
94 
95  std::string do_getcwd (void) const;
96 
97  std::string do_get_home_directory (void) const;
98 
99  std::string do_get_temp_directory (void) const;
100 
101  std::string do_get_user_name (void) const;
102 
103  std::string do_get_host_name (void) const;
104 
105  std::string do_getenv (const std::string& name) const;
106 
107  void do_putenv (const std::string& name, const std::string& value) const;
108 
109  bool do_chdir (const std::string& newdir);
110 
111  void do_set_program_name (const std::string& s) const;
112 
113  void pathname_backup (std::string& path, int n) const;
114 
115  void error (int) const;
116 
117  void error (const std::string&) const;
118 
119  // No copying!
120 
121  env (const env&);
122 
123  env& operator = (const env&);
124 
125  // The real thing.
126  static env *instance;
127 
128  static void cleanup_instance (void) { delete instance; instance = 0; }
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 ("use 'octave::sys::env' instead")
156 typedef octave::sys::env octave_env;
157 
158 #endif
159 
160 #endif
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
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:570
s
Definition: file-io.cc:2682
bool follow_symbolic_links
Definition: oct-env.h:132
std::string host_name
Definition: oct-env.h:148
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
static env * instance
Definition: oct-env.h:126
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
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol zero divided by nd tex zero divided by nd ifnottex and any operation involving another NaN value(5+NaN).Note that NaN always compares not equal to NaN(NaN!
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:854