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 |
|
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 |
3504
|
42 static std::string base_pathname (const std::string& s); |
2926
|
43 |
4097
|
44 static std::string make_absolute (const std::string& s, |
|
45 const std::string& dot_path); |
2926
|
46 |
3504
|
47 static std::string getcwd (void); |
2926
|
48 |
3504
|
49 static std::string get_home_directory (void); |
2926
|
50 |
3504
|
51 static std::string get_program_name (void); |
2926
|
52 |
3504
|
53 static std::string get_program_invocation_name (void); |
2926
|
54 |
3504
|
55 static std::string get_user_name (void); |
2926
|
56 |
3504
|
57 static std::string get_host_name (void); |
2926
|
58 |
3504
|
59 static std::string getenv (const std::string& name); |
2926
|
60 |
3504
|
61 static void putenv (const std::string& name, const std::string& value); |
2926
|
62 |
3504
|
63 static bool chdir (const std::string& newdir); |
2926
|
64 |
3504
|
65 static void set_program_name (const std::string& s); |
2926
|
66 |
|
67 private: |
|
68 |
|
69 static bool instance_ok (void); |
|
70 |
3504
|
71 std::string do_polite_directory_format (const std::string& name) const; |
2926
|
72 |
3504
|
73 bool do_absolute_pathname (const std::string& s) const; |
2926
|
74 |
3504
|
75 std::string do_base_pathname (const std::string& s) const; |
2926
|
76 |
4097
|
77 std::string do_make_absolute (const std::string& s, |
|
78 const std::string& dot_path) const; |
2926
|
79 |
4097
|
80 std::string do_getcwd (void) const; |
2926
|
81 |
3504
|
82 std::string do_get_home_directory (void) const; |
2926
|
83 |
3504
|
84 std::string do_get_user_name (void) const; |
2926
|
85 |
3504
|
86 std::string do_get_host_name (void) const; |
2926
|
87 |
3504
|
88 std::string do_getenv (const std::string& name) const; |
2926
|
89 |
3504
|
90 void do_putenv (const std::string& name, const std::string& value) const; |
2926
|
91 |
3504
|
92 bool do_chdir (const std::string& newdir); |
2926
|
93 |
3504
|
94 void do_set_program_name (const std::string& s) const; |
2926
|
95 |
3504
|
96 void pathname_backup (std::string& path, int n) const; |
2926
|
97 |
|
98 void error (int) const; |
|
99 |
3504
|
100 void error (const std::string&) const; |
2926
|
101 |
|
102 // No copying! |
|
103 |
|
104 octave_env (const octave_env&); |
|
105 |
|
106 octave_env& operator = (const octave_env&); |
|
107 |
|
108 // The real thing. |
|
109 static octave_env *instance; |
|
110 |
|
111 // TRUE means follow symbolic links that point to directories just |
|
112 // as if they are real directories. |
|
113 bool follow_symbolic_links; |
|
114 |
|
115 // TRUE means that pwd always give verbatim directory, regardless |
|
116 // of symbolic link following. |
|
117 bool verbatim_pwd; |
|
118 |
|
119 // Where are we? |
4097
|
120 mutable std::string current_directory; |
2926
|
121 |
|
122 // Etc. |
3504
|
123 mutable std::string program_name; |
2926
|
124 |
3504
|
125 mutable std::string program_invocation_name; |
2926
|
126 |
3504
|
127 mutable std::string user_name; |
2926
|
128 |
3504
|
129 mutable std::string host_name; |
2926
|
130 }; |
|
131 |
|
132 #endif |
|
133 |
|
134 /* |
|
135 ;;; Local Variables: *** |
|
136 ;;; mode: C++ *** |
|
137 ;;; End: *** |
|
138 */ |