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 #ifdef HAVE_SYS_TYPES_H
00029 #include <sys/types.h>
00030 #endif
00031
00032 #include "str-vec.h"
00033
00034 struct
00035 OCTAVE_API
00036 file_ops
00037 {
00038 public:
00039
00040 static int mkdir (const std::string&, mode_t);
00041 static int mkdir (const std::string&, mode_t, std::string&);
00042
00043 static int mkfifo (const std::string&, mode_t);
00044 static int mkfifo (const std::string&, mode_t, std::string&);
00045
00046 static int link (const std::string&, const std::string&);
00047 static int link (const std::string&, const std::string&, std::string&);
00048
00049 static int symlink (const std::string&, const std::string&);
00050 static int symlink (const std::string&, const std::string&, std::string&);
00051
00052 static int readlink (const std::string&, std::string&);
00053 static int readlink (const std::string&, std::string&, std::string&);
00054
00055 static int rename (const std::string&, const std::string&);
00056 static int rename (const std::string&, const std::string&, std::string&);
00057
00058 static int rmdir (const std::string&);
00059 static int rmdir (const std::string&, std::string&);
00060
00061 static int recursive_rmdir (const std::string&);
00062 static int recursive_rmdir (const std::string&, std::string&);
00063
00064 static std::string canonicalize_file_name (const std::string&);
00065 static std::string canonicalize_file_name (const std::string&, std::string&);
00066
00067 static std::string tempnam (const std::string&, const std::string&);
00068 static std::string tempnam (const std::string&, const std::string&,
00069 std::string&);
00070
00071 typedef std::string (*tilde_expansion_hook) (const std::string&);
00072
00073 static tilde_expansion_hook tilde_expansion_preexpansion_hook;
00074
00075 static tilde_expansion_hook tilde_expansion_failure_hook;
00076
00077 static string_vector tilde_additional_prefixes;
00078
00079 static string_vector tilde_additional_suffixes;
00080
00081 static std::string tilde_expand (const std::string&);
00082 static string_vector tilde_expand (const string_vector&);
00083
00084 static int umask (mode_t);
00085
00086 static int unlink (const std::string&);
00087 static int unlink (const std::string&, std::string&);
00088
00089 static bool is_dir_sep (char c)
00090 {
00091 std::string tmp = dir_sep_chars ();
00092 return tmp.find (c) != std::string::npos;
00093 }
00094
00095 static std::string concat (const std::string&, const std::string&);
00096
00097 static char dir_sep_char (void)
00098 {
00099 return static_members::dir_sep_char ();
00100 }
00101
00102 static std::string dir_sep_str (void)
00103 {
00104 return static_members::dir_sep_str ();
00105 }
00106
00107 static std::string dir_sep_chars (void)
00108 {
00109 return static_members::dir_sep_chars ();
00110 }
00111
00112
00113 static std::string tail (std::string path)
00114 {
00115 size_t ipos = path.find_last_of (dir_sep_chars ());
00116
00117 if (ipos != std::string::npos)
00118 ipos++;
00119 else
00120 ipos = 0;
00121
00122 return path.substr (ipos);
00123 }
00124
00125 private:
00126
00127
00128
00129
00130
00131 class static_members
00132 {
00133 public:
00134
00135 static_members (void);
00136
00137 static char dir_sep_char (void)
00138 {
00139 return instance_ok () ? instance->xdir_sep_char : 0;
00140 }
00141
00142 static std::string dir_sep_str (void)
00143 {
00144 return instance_ok () ? instance->xdir_sep_str : std::string ();
00145 }
00146
00147 static std::string dir_sep_chars (void)
00148 {
00149 return instance_ok () ? instance->xdir_sep_chars : std::string ();
00150 }
00151
00152 private:
00153
00154
00155 static static_members *instance;
00156
00157
00158
00159 static_members (const static_members&);
00160
00161 static_members& operator = (const static_members&);
00162
00163 static bool instance_ok (void);
00164
00165 char xdir_sep_char;
00166 std::string xdir_sep_str;
00167 std::string xdir_sep_chars;
00168 };
00169 };
00170
00171 #endif
00172
00173
00174
00175
00176
00177