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