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