2926
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 2000, 2002, 2005, 2006, 2007 John W. Eaton |
2926
|
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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2926
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2926
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_env_h) |
|
24 #define octave_env_h 1 |
|
25 |
|
26 #include <string> |
|
27 |
|
28 class |
6108
|
29 OCTAVE_API |
2926
|
30 octave_env |
|
31 { |
|
32 protected: |
|
33 |
|
34 octave_env (void); |
|
35 |
|
36 public: |
|
37 |
3504
|
38 static std::string polite_directory_format (const std::string& name); |
2926
|
39 |
3504
|
40 static bool absolute_pathname (const std::string& s); |
2926
|
41 |
6838
|
42 static bool rooted_relative_pathname (const std::string& s); |
|
43 |
3504
|
44 static std::string base_pathname (const std::string& s); |
2926
|
45 |
4097
|
46 static std::string make_absolute (const std::string& s, |
|
47 const std::string& dot_path); |
2926
|
48 |
3504
|
49 static std::string getcwd (void); |
2926
|
50 |
3504
|
51 static std::string get_home_directory (void); |
2926
|
52 |
3504
|
53 static std::string get_program_name (void); |
2926
|
54 |
3504
|
55 static std::string get_program_invocation_name (void); |
2926
|
56 |
3504
|
57 static std::string get_user_name (void); |
2926
|
58 |
3504
|
59 static std::string get_host_name (void); |
2926
|
60 |
3504
|
61 static std::string getenv (const std::string& name); |
2926
|
62 |
3504
|
63 static void putenv (const std::string& name, const std::string& value); |
2926
|
64 |
5489
|
65 static bool have_x11_display (void); |
|
66 |
3504
|
67 static bool chdir (const std::string& newdir); |
2926
|
68 |
3504
|
69 static void set_program_name (const std::string& s); |
2926
|
70 |
|
71 private: |
|
72 |
|
73 static bool instance_ok (void); |
|
74 |
3504
|
75 std::string do_polite_directory_format (const std::string& name) const; |
2926
|
76 |
3504
|
77 bool do_absolute_pathname (const std::string& s) const; |
2926
|
78 |
6838
|
79 bool do_rooted_relative_pathname (const std::string& s) const; |
|
80 |
3504
|
81 std::string do_base_pathname (const std::string& s) const; |
2926
|
82 |
4097
|
83 std::string do_make_absolute (const std::string& s, |
|
84 const std::string& dot_path) const; |
2926
|
85 |
4097
|
86 std::string do_getcwd (void) const; |
2926
|
87 |
3504
|
88 std::string do_get_home_directory (void) const; |
2926
|
89 |
3504
|
90 std::string do_get_user_name (void) const; |
2926
|
91 |
3504
|
92 std::string do_get_host_name (void) const; |
2926
|
93 |
3504
|
94 std::string do_getenv (const std::string& name) const; |
2926
|
95 |
3504
|
96 void do_putenv (const std::string& name, const std::string& value) const; |
2926
|
97 |
3504
|
98 bool do_chdir (const std::string& newdir); |
2926
|
99 |
3504
|
100 void do_set_program_name (const std::string& s) const; |
2926
|
101 |
3504
|
102 void pathname_backup (std::string& path, int n) const; |
2926
|
103 |
|
104 void error (int) const; |
|
105 |
3504
|
106 void error (const std::string&) const; |
2926
|
107 |
|
108 // No copying! |
|
109 |
|
110 octave_env (const octave_env&); |
|
111 |
|
112 octave_env& operator = (const octave_env&); |
|
113 |
|
114 // The real thing. |
|
115 static octave_env *instance; |
|
116 |
|
117 // TRUE means follow symbolic links that point to directories just |
|
118 // as if they are real directories. |
|
119 bool follow_symbolic_links; |
|
120 |
|
121 // TRUE means that pwd always give verbatim directory, regardless |
|
122 // of symbolic link following. |
|
123 bool verbatim_pwd; |
|
124 |
|
125 // Where are we? |
4097
|
126 mutable std::string current_directory; |
2926
|
127 |
|
128 // Etc. |
3504
|
129 mutable std::string program_name; |
2926
|
130 |
3504
|
131 mutable std::string program_invocation_name; |
2926
|
132 |
3504
|
133 mutable std::string user_name; |
2926
|
134 |
3504
|
135 mutable std::string host_name; |
2926
|
136 }; |
|
137 |
|
138 #endif |
|
139 |
|
140 /* |
|
141 ;;; Local Variables: *** |
|
142 ;;; mode: C++ *** |
|
143 ;;; End: *** |
|
144 */ |