Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_file_ops_h)
00024 #define octave_file_ops_h 1
00025
00026 #include <string>
00027
00028 #include <sys/types.h>
00029
00030 #include "str-vec.h"
00031
00032 struct
00033 OCTAVE_API
00034 file_ops
00035 {
00036 public:
00037
00038
00039
00040
00041
00042 file_ops (char dir_sep_char_arg = 0,
00043 const std::string& dir_sep_str_arg = std::string ("/"),
00044 const std::string& dir_sep_chars_arg = std::string ("/"))
00045 : xdir_sep_char (dir_sep_char_arg), xdir_sep_str (dir_sep_str_arg),
00046 xdir_sep_chars (dir_sep_chars_arg) { }
00047
00048 typedef std::string (*tilde_expansion_hook) (const std::string&);
00049
00050 static tilde_expansion_hook tilde_expansion_preexpansion_hook;
00051
00052 static tilde_expansion_hook tilde_expansion_failure_hook;
00053
00054 static string_vector tilde_additional_prefixes;
00055
00056 static string_vector tilde_additional_suffixes;
00057
00058 static char dir_sep_char (void)
00059 {
00060 return instance_ok () ? instance->xdir_sep_char : 0;
00061 }
00062
00063 static std::string dir_sep_str (void)
00064 {
00065 return instance_ok () ? instance->xdir_sep_str : std::string ();
00066 }
00067
00068 static std::string dir_sep_chars (void)
00069 {
00070 return instance_ok () ? instance->xdir_sep_chars : std::string ();
00071 }
00072
00073 static bool is_dir_sep (char c)
00074 {
00075 std::string tmp = dir_sep_chars ();
00076 return tmp.find (c) != std::string::npos;
00077 }
00078
00079 static std::string tilde_expand (const std::string&);
00080
00081 static string_vector tilde_expand (const string_vector&);
00082
00083 static std::string concat (const std::string&, const std::string&);
00084
00085
00086 static std::string tail (const std::string& path)
00087 {
00088 size_t ipos = path.find_last_of (dir_sep_chars ());
00089
00090 if (ipos != std::string::npos)
00091 ipos++;
00092 else
00093 ipos = 0;
00094
00095 return path.substr (ipos);
00096 }
00097
00098 private:
00099
00100 static file_ops *instance;
00101
00102 static void cleanup_instance (void) { delete instance; instance = 0; }
00103
00104
00105
00106 file_ops (const file_ops&);
00107
00108 file_ops& operator = (const file_ops&);
00109
00110 static bool instance_ok (void);
00111
00112 char xdir_sep_char;
00113 std::string xdir_sep_str;
00114 std::string xdir_sep_chars;
00115 };
00116
00117
00118
00119
00120
00121 extern OCTAVE_API int
00122 octave_mkdir (const std::string& nm, mode_t md);
00123
00124 extern OCTAVE_API int
00125 octave_mkdir (const std::string& nm, mode_t md, std::string& msg);
00126
00127 extern OCTAVE_API int
00128 octave_mkfifo (const std::string& nm, mode_t md);
00129
00130 extern OCTAVE_API int
00131 octave_mkfifo (const std::string& nm, mode_t md, std::string& msg);
00132
00133 extern OCTAVE_API int
00134 octave_link (const std::string&, const std::string&);
00135
00136 extern OCTAVE_API int
00137 octave_link (const std::string&, const std::string&, std::string&);
00138
00139 extern OCTAVE_API int
00140 octave_symlink (const std::string&, const std::string&);
00141
00142 extern OCTAVE_API int
00143 octave_symlink (const std::string&, const std::string&, std::string&);
00144
00145 extern OCTAVE_API int
00146 octave_readlink (const std::string&, std::string&);
00147
00148 extern OCTAVE_API int
00149 octave_readlink (const std::string&, std::string&, std::string&);
00150
00151 extern OCTAVE_API int
00152 octave_rename (const std::string&, const std::string&);
00153
00154 extern OCTAVE_API int
00155 octave_rename (const std::string&, const std::string&, std::string&);
00156
00157 extern OCTAVE_API int
00158 octave_rmdir (const std::string&);
00159
00160 extern OCTAVE_API int
00161 octave_rmdir (const std::string&, std::string&);
00162
00163 extern OCTAVE_API int
00164 octave_recursive_rmdir (const std::string&);
00165
00166 extern OCTAVE_API int
00167 octave_recursive_rmdir (const std::string&, std::string&);
00168
00169 extern OCTAVE_API int
00170 octave_umask (mode_t);
00171
00172 extern OCTAVE_API int
00173 octave_unlink (const std::string&);
00174
00175 extern OCTAVE_API int
00176 octave_unlink (const std::string&, std::string&);
00177
00178 extern OCTAVE_API std::string
00179 octave_tempnam (const std::string&, const std::string&);
00180
00181 extern OCTAVE_API std::string
00182 octave_tempnam (const std::string&, const std::string&, std::string&);
00183
00184 extern OCTAVE_API std::string
00185 octave_canonicalize_file_name (const std::string&);
00186
00187 extern OCTAVE_API std::string
00188 octave_canonicalize_file_name (const std::string&, std::string&);
00189
00190 #endif