Go to the documentation of this file.00001
00002 #ifndef vul_file_h_
00003 #define vul_file_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <vcl_string.h>
00022 #include <vxl_config.h>
00023
00024
00025
00026 struct vul_file
00027 {
00028
00029 static vcl_string get_cwd();
00030
00031
00032 static bool change_directory(char const* dirname);
00033 static bool change_directory(vcl_string const& dirname) {
00034 return change_directory(dirname.c_str());
00035 }
00036
00037
00038
00039
00040 static bool make_directory(char const* filename);
00041 static bool make_directory(vcl_string const& filename) {
00042 return make_directory(filename.c_str());
00043 }
00044
00045
00046
00047 static bool make_directory_path(char const* filename);
00048 static bool make_directory_path(vcl_string const& filename) {
00049 return make_directory_path(filename.c_str());
00050 }
00051
00052
00053 static bool is_directory(char const* filename);
00054 static bool is_directory(const vcl_string& filename) {
00055 return is_directory(filename.c_str());
00056 }
00057
00058 #if defined(VCL_WIN32) && !defined(__CYGWIN__)
00059
00060 static bool is_drive(char const* filename);
00061 static bool is_drive(const vcl_string& filename) {
00062 return is_drive(filename.c_str());
00063 }
00064 #endif
00065
00066
00067 static vcl_string expand_tilde(char const* filename);
00068 static vcl_string expand_tilde(vcl_string const& filename) {
00069 return expand_tilde(filename.c_str());
00070 }
00071
00072
00073 static bool exists(char const* filename);
00074 static bool exists(vcl_string const& filename) {
00075 return exists(filename.c_str());
00076 }
00077
00078
00079 static unsigned long size(char const* filename);
00080 static unsigned long size(vcl_string filename) { return size(filename.c_str()); }
00081
00082
00083 static vcl_string dirname(char const* filename);
00084 static vcl_string dirname(vcl_string const& filename) {
00085 return dirname(filename.c_str());
00086 }
00087
00088
00089 static vcl_string extension(char const* filename);
00090 static vcl_string extension(vcl_string const& filename) {
00091 return extension( filename.c_str() );
00092 }
00093
00094
00095
00096 static vcl_string basename(char const* filename, char const* suffix = 0);
00097 static vcl_string basename(vcl_string const& filename, char const* suffix = 0) {
00098 return basename(filename.c_str(), suffix );
00099 }
00100
00101
00102 static vcl_string strip_directory(char const* filename);
00103 static vcl_string strip_directory(vcl_string const &filename)
00104 { return strip_directory(filename.c_str()); }
00105
00106
00107 static vcl_string strip_extension(char const* filename);
00108 static vcl_string strip_extension(vcl_string const &filename)
00109 { return strip_extension(filename.c_str()); }
00110
00111
00112
00113
00114
00115 static bool delete_file_glob(vcl_string const& file_glob);
00116 static bool delete_file_glob(char const* file_glob)
00117 { return delete_file_glob(vcl_string(file_glob)); }
00118
00119
00120 #if defined(VCL_WIN32) && VXL_USE_WIN_WCHAR_T
00121
00122
00123
00124 static vcl_string get_cwd(char* )
00125 { return get_cwd(); }
00126
00127
00128 static std::wstring get_cwd(wchar_t* dummy);
00129
00130
00131 static bool change_directory(wchar_t const* dirname);
00132 static bool change_directory(std::wstring const& dirname) {
00133 return change_directory(dirname.c_str());
00134 }
00135
00136
00137
00138
00139 static bool make_directory(wchar_t const* filename);
00140 static bool make_directory(std::wstring const& filename) {
00141 return make_directory(filename.c_str());
00142 }
00143
00144
00145
00146 static bool make_directory_path(wchar_t const* filename);
00147 static bool make_directory_path(std::wstring const& filename) {
00148 return make_directory_path(filename.c_str());
00149 }
00150
00151
00152 static bool is_directory(wchar_t const* filename);
00153 static bool is_directory(const std::wstring& filename) {
00154 return is_directory(filename.c_str());
00155 }
00156
00157
00158 static bool is_drive(wchar_t const* filename);
00159 static bool is_drive(const std::wstring& filename) {
00160 return is_drive(filename.c_str());
00161 }
00162
00163
00164 static std::wstring expand_tilde(wchar_t const* filename) {
00165
00166 return std::wstring(filename);
00167 }
00168 static std::wstring expand_tilde(std::wstring const& filename) {
00169
00170 return filename;
00171 }
00172
00173
00174 static bool exists(wchar_t const* filename);
00175 static bool exists(std::wstring const& filename) {
00176 return exists(filename.c_str());
00177 }
00178
00179
00180
00181
00182
00183
00184 static std::wstring dirname(wchar_t const* filename);
00185 static std::wstring dirname(std::wstring const& filename) {
00186 return dirname(filename.c_str());
00187 }
00188
00189
00190 static std::wstring extension(wchar_t const* filename);
00191 static std::wstring extension(std::wstring const& filename) {
00192 return extension( filename.c_str() );
00193 }
00194
00195
00196 static std::wstring basename(wchar_t const* filename, wchar_t const* suffix = 0);
00197 static std::wstring basename(std::wstring const& filename, wchar_t const* suffix = 0) {
00198 return basename(filename.c_str(), suffix );
00199 }
00200
00201
00202 static std::wstring strip_directory(wchar_t const* filename);
00203 static std::wstring strip_directory(std::wstring const &filename)
00204 { return strip_directory(filename.c_str()); }
00205
00206
00207 static std::wstring strip_extension(wchar_t const* filename);
00208 static std::wstring strip_extension(std::wstring const &filename)
00209 { return strip_extension(filename.c_str()); }
00210
00211 #endif
00212 };
00213
00214 inline bool vul_file_exists(char const *f) { return vul_file::exists(f); }
00215 inline bool vul_file_exists(vcl_string f) { return vul_file::exists(f); }
00216
00217 inline bool vul_file_is_directory(char const *f) { return vul_file::is_directory(f); }
00218 inline bool vul_file_is_directory(vcl_string f) { return vul_file::is_directory(f); }
00219
00220 inline unsigned long vul_file_size(char const *f) { return vul_file::size(f); }
00221 inline unsigned long vul_file_size(vcl_string f) { return vul_file::size(f); }
00222
00223 inline vcl_string vul_file_extension(char const *f) { return vul_file::extension(f); }
00224 inline vcl_string vul_file_extension(vcl_string f) { return vul_file_extension(f.c_str()); }
00225
00226 #endif // vul_file_h_