Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1996, 1997, 2000, 2002, 2005, 2006, 2007 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_env_h) 00024 #define octave_env_h 1 00025 00026 #include <string> 00027 00028 class 00029 OCTAVE_API 00030 octave_env 00031 { 00032 protected: 00033 00034 octave_env (void); 00035 00036 public: 00037 00038 static std::string polite_directory_format (const std::string& name); 00039 00040 static bool absolute_pathname (const std::string& s); 00041 00042 static bool rooted_relative_pathname (const std::string& s); 00043 00044 static std::string base_pathname (const std::string& s); 00045 00046 static std::string make_absolute (const std::string& s, 00047 const std::string& dot_path); 00048 00049 static std::string getcwd (void); 00050 00051 static std::string get_home_directory (void); 00052 00053 static std::string get_program_name (void); 00054 00055 static std::string get_program_invocation_name (void); 00056 00057 static std::string get_user_name (void); 00058 00059 static std::string get_host_name (void); 00060 00061 static std::string getenv (const std::string& name); 00062 00063 static void putenv (const std::string& name, const std::string& value); 00064 00065 static bool have_x11_display (void); 00066 00067 static bool chdir (const std::string& newdir); 00068 00069 static void set_program_name (const std::string& s); 00070 00071 private: 00072 00073 static bool instance_ok (void); 00074 00075 std::string do_polite_directory_format (const std::string& name) const; 00076 00077 bool do_absolute_pathname (const std::string& s) const; 00078 00079 bool do_rooted_relative_pathname (const std::string& s) const; 00080 00081 std::string do_base_pathname (const std::string& s) const; 00082 00083 std::string do_make_absolute (const std::string& s, 00084 const std::string& dot_path) const; 00085 00086 std::string do_getcwd (void) const; 00087 00088 std::string do_get_home_directory (void) const; 00089 00090 std::string do_get_user_name (void) const; 00091 00092 std::string do_get_host_name (void) const; 00093 00094 std::string do_getenv (const std::string& name) const; 00095 00096 void do_putenv (const std::string& name, const std::string& value) const; 00097 00098 bool do_chdir (const std::string& newdir); 00099 00100 void do_set_program_name (const std::string& s) const; 00101 00102 void pathname_backup (std::string& path, int n) const; 00103 00104 void error (int) const; 00105 00106 void error (const std::string&) const; 00107 00108 // No copying! 00109 00110 octave_env (const octave_env&); 00111 00112 octave_env& operator = (const octave_env&); 00113 00114 // The real thing. 00115 static octave_env *instance; 00116 00117 // TRUE means follow symbolic links that point to directories just 00118 // as if they are real directories. 00119 bool follow_symbolic_links; 00120 00121 // TRUE means that pwd always give verbatim directory, regardless 00122 // of symbolic link following. 00123 bool verbatim_pwd; 00124 00125 // Where are we? 00126 mutable std::string current_directory; 00127 00128 // Etc. 00129 mutable std::string program_name; 00130 00131 mutable std::string program_invocation_name; 00132 00133 mutable std::string user_name; 00134 00135 mutable std::string host_name; 00136 }; 00137 00138 #endif 00139 00140 /* 00141 ;;; Local Variables: *** 00142 ;;; mode: C++ *** 00143 ;;; End: *** 00144 */