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
00103
00104 file_ops (const file_ops&);
00105
00106 file_ops& operator = (const file_ops&);
00107
00108 static bool instance_ok (void);
00109
00110 char xdir_sep_char;
00111 std::string xdir_sep_str;
00112 std::string xdir_sep_chars;
00113 };
00114
00115
00116
00117
00118
00119 extern OCTAVE_API int
00120 octave_mkdir (const std::string& nm, mode_t md);
00121
00122 extern OCTAVE_API int
00123 octave_mkdir (const std::string& nm, mode_t md, std::string& msg);
00124
00125 extern OCTAVE_API int
00126 octave_mkfifo (const std::string& nm, mode_t md);
00127
00128 extern OCTAVE_API int
00129 octave_mkfifo (const std::string& nm, mode_t md, std::string& msg);
00130
00131 extern OCTAVE_API int
00132 octave_link (const std::string&, const std::string&);
00133
00134 extern OCTAVE_API int
00135 octave_link (const std::string&, const std::string&, std::string&);
00136
00137 extern OCTAVE_API int
00138 octave_symlink (const std::string&, const std::string&);
00139
00140 extern OCTAVE_API int
00141 octave_symlink (const std::string&, const std::string&, std::string&);
00142
00143 extern OCTAVE_API int
00144 octave_readlink (const std::string&, std::string&);
00145
00146 extern OCTAVE_API int
00147 octave_readlink (const std::string&, std::string&, std::string&);
00148
00149 extern OCTAVE_API int
00150 octave_rename (const std::string&, const std::string&);
00151
00152 extern OCTAVE_API int
00153 octave_rename (const std::string&, const std::string&, std::string&);
00154
00155 extern OCTAVE_API int
00156 octave_rmdir (const std::string&);
00157
00158 extern OCTAVE_API int
00159 octave_rmdir (const std::string&, std::string&);
00160
00161 extern OCTAVE_API int
00162 octave_recursive_rmdir (const std::string&);
00163
00164 extern OCTAVE_API int
00165 octave_recursive_rmdir (const std::string&, std::string&);
00166
00167 extern OCTAVE_API int
00168 octave_umask (mode_t);
00169
00170 extern OCTAVE_API int
00171 octave_unlink (const std::string&);
00172
00173 extern OCTAVE_API int
00174 octave_unlink (const std::string&, std::string&);
00175
00176 extern OCTAVE_API std::string
00177 octave_tempnam (const std::string&, const std::string&);
00178
00179 extern OCTAVE_API std::string
00180 octave_tempnam (const std::string&, const std::string&, std::string&);
00181
00182 extern OCTAVE_API std::string
00183 octave_canonicalize_file_name (const std::string&);
00184
00185 extern OCTAVE_API std::string
00186 octave_canonicalize_file_name (const std::string&, std::string&);
00187
00188 #endif