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