author | Michael Krelin <hacker@klever.net> | 2005-04-25 16:36:32 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-04-25 16:36:32 (UTC) |
commit | 981b219f5297ad2ccc1fc1d0e24e41ec009c35a3 (patch) (unidiff) | |
tree | 9fa81d7fe70883ad26d946c902ba06edcebd4516 /include/sitecing | |
parent | 54e344b7e3623e807b893b7febad3adfc6c1648f (diff) | |
download | sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.zip sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.tar.gz sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.tar.bz2 |
moved a few utility functions to konforka and bumped konforka version requirement accordingly
-rw-r--r-- | include/sitecing/sitecing_util.h | 85 |
1 files changed, 2 insertions, 83 deletions
diff --git a/include/sitecing/sitecing_util.h b/include/sitecing/sitecing_util.h index d1a6c4a..f642c74 100644 --- a/include/sitecing/sitecing_util.h +++ b/include/sitecing/sitecing_util.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <sys/types.h> | 4 | #include <sys/types.h> |
5 | #include <string> | 5 | #include <string> |
6 | #include <konforka/exception.h> | 6 | #include <konforka/exception.h> |
7 | #include <konforka/util.h> | ||
7 | 8 | ||
8 | /** | 9 | /** |
9 | * @file | 10 | * @file |
@@ -21,14 +22,7 @@ namespace sitecing { | |||
21 | utility_error(const string& fi,const string& fu,int l,const string& w) | 22 | utility_error(const string& fi,const string& fu,int l,const string& w) |
22 | : konforka::exception(fi,fu,l,w) { } | 23 | : konforka::exception(fi,fu,l,w) { } |
23 | }; | 24 | }; |
24 | /** | 25 | |
25 | * Restricted sequence encountered. | ||
26 | */ | ||
27 | class utility_restricted_sequence : public utility_error { | ||
28 | public: | ||
29 | utility_restricted_sequence(const string& fi,const string& fu,int l,const string& w) | ||
30 | : utility_error(fi,fu,l,w) { } | ||
31 | }; | ||
32 | /** | 26 | /** |
33 | * No prefix or suffix found to strip out. | 27 | * No prefix or suffix found to strip out. |
34 | */ | 28 | */ |
@@ -55,16 +49,6 @@ namespace sitecing { | |||
55 | }; | 49 | }; |
56 | 50 | ||
57 | /** | 51 | /** |
58 | * Went up beyond root. | ||
59 | * @todo TODO: wish I could remember the details -- document me. | ||
60 | */ | ||
61 | class utility_beyond_root : public utility_error { | ||
62 | public: | ||
63 | utility_beyond_root(const string& fi,const string& fu,int l,const string& w) | ||
64 | : utility_error(fi,fu,l,w) { } | ||
65 | }; | ||
66 | |||
67 | /** | ||
68 | * The file lock object. Released at the object destruction. | 52 | * The file lock object. Released at the object destruction. |
69 | */ | 53 | */ |
70 | class file_lock { | 54 | class file_lock { |
@@ -215,48 +199,6 @@ namespace sitecing { | |||
215 | }; | 199 | }; |
216 | 200 | ||
217 | /** | 201 | /** |
218 | * normalize_path options enumeration. | ||
219 | * @see normalize_path() | ||
220 | */ | ||
221 | enum normalize_path_options { | ||
222 | /** | ||
223 | * Restrict the /../ sequence. | ||
224 | */ | ||
225 | restrict_dotdot = 1, | ||
226 | /** | ||
227 | * Strip out the leading slash. | ||
228 | */ | ||
229 | strip_leading_slash = 2, | ||
230 | /** | ||
231 | * Strip out the trailing slash. | ||
232 | */ | ||
233 | strip_trailing_slash = 4 | ||
234 | }; | ||
235 | /** | ||
236 | * combine_path options enumeration. | ||
237 | * @see combine_path() | ||
238 | */ | ||
239 | enum combine_path_options { | ||
240 | /** | ||
241 | * The origin is file. Otherwise it is directory. | ||
242 | */ | ||
243 | origin_is_file = 1, | ||
244 | /** | ||
245 | * Fail if we've gone up beyond root. | ||
246 | */ | ||
247 | fail_beyond_root = 2 | ||
248 | }; | ||
249 | |||
250 | /** | ||
251 | * Normalize pathname by stripping duplicate slashes, etc. | ||
252 | * @param path the path name. | ||
253 | * @param opts options. | ||
254 | * @return the normalized path. | ||
255 | * @see normalize_path_options | ||
256 | * @todo TODO: document exceptions. | ||
257 | */ | ||
258 | string normalize_path(const string& path,int opts=(restrict_dotdot|strip_trailing_slash)); | ||
259 | /** | ||
260 | * Strip prefix from the string. | 202 | * Strip prefix from the string. |
261 | * @param str the string. | 203 | * @param str the string. |
262 | * @param prefix prefix to strip. | 204 | * @param prefix prefix to strip. |
@@ -272,29 +214,6 @@ namespace sitecing { | |||
272 | * @todo TODO: document exceptions. | 214 | * @todo TODO: document exceptions. |
273 | */ | 215 | */ |
274 | string strip_suffix(const string& str,const string& suffix); | 216 | string strip_suffix(const string& str,const string& suffix); |
275 | /** | ||
276 | * Get the directory part of the filename. | ||
277 | * @param filename the full file name. | ||
278 | * @return the directory part. | ||
279 | */ | ||
280 | string dir_name(const string& filename); | ||
281 | /** | ||
282 | * Combine path with the relative path. | ||
283 | * @param origin the origin. | ||
284 | * @param relative relative path to combine origin with. | ||
285 | * @param opts options. | ||
286 | * @return the pathc combined. | ||
287 | * @see combine_path_options | ||
288 | * @todo TODO: document exceptions. | ||
289 | */ | ||
290 | string combine_path(const string& origin,const string& relative,int opts=origin_is_file); | ||
291 | |||
292 | /** | ||
293 | * Create directory and parent directories if needed. | ||
294 | * @param path the pathname. | ||
295 | * @param mode the mode for newly created directories. | ||
296 | */ | ||
297 | void make_path(const string& path,mode_t mode); | ||
298 | 217 | ||
299 | /** | 218 | /** |
300 | * Change to the directory and pop back at object's destruction (e.g. when | 219 | * Change to the directory and pop back at object's destruction (e.g. when |