summaryrefslogtreecommitdiffabout
path: root/lib
Unidiff
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/sitecing_util.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sitecing_util.cc b/lib/sitecing_util.cc
index 9b6c54e..5466b28 100644
--- a/lib/sitecing_util.cc
+++ b/lib/sitecing_util.cc
@@ -239,40 +239,41 @@ namespace sitecing {
239 lsl = rv.length(); 239 lsl = rv.length();
240 rv += '/'; 240 rv += '/';
241 rv += r.substr(0,sl); 241 rv += r.substr(0,sl);
242 r.erase(0,sl+1); 242 r.erase(0,sl+1);
243 } 243 }
244 } 244 }
245 if(r.empty()) 245 if(r.empty())
246 return rv+'/'; 246 return rv+'/';
247 if(r.length()==2 && r[0]=='.' && r[0]=='.') { 247 if(r.length()==2 && r[0]=='.' && r[0]=='.') {
248 if(lsl==string::npos) { 248 if(lsl==string::npos) {
249 if(rv.empty() & (opts&fail_beyond_root)) 249 if(rv.empty() & (opts&fail_beyond_root))
250 throw utility_beyond_root(CODEPOINT,"went beyond root while combining path"); 250 throw utility_beyond_root(CODEPOINT,"went beyond root while combining path");
251 return "/"; 251 return "/";
252 }else{ 252 }else{
253 rv.erase(lsl+1); 253 rv.erase(lsl+1);
254 return rv; 254 return rv;
255 } 255 }
256 } 256 }
257 rv += '/'; 257 rv += '/';
258 rv += r; 258 rv += r;
259 return rv; 259 return rv;
260 } 260 }
261 261
262 void auto_chdir::pushdir(const string& td,bool ap) { 262 void auto_chdir::pushdir(const string& td,bool ap) {
263 char *tmp = get_current_dir_name(); 263 /* TODO: make use of fchdir(2) instead */
264 char *tmp = getcwd(0,0);
264 assert(tmp); 265 assert(tmp);
265 saved_pwd = tmp; 266 saved_pwd = tmp;
266 free(tmp); 267 free(tmp);
267 autopop=ap; 268 autopop=ap;
268 if(chdir(td.c_str())) 269 if(chdir(td.c_str()))
269 throw konforka::exception(CODEPOINT,"failed to chdir()"); 270 throw konforka::exception(CODEPOINT,"failed to chdir()");
270 } 271 }
271 void auto_chdir::popdir() { 272 void auto_chdir::popdir() {
272 autopop=false; 273 autopop=false;
273 if(chdir(saved_pwd.c_str())) 274 if(chdir(saved_pwd.c_str()))
274 throw konforka::exception(CODEPOINT,"failed to chdir()"); 275 throw konforka::exception(CODEPOINT,"failed to chdir()");
275 // XXX: or should it be thrown? after all we call it from destructor... 276 // XXX: or should it be thrown? after all we call it from destructor...
276 } 277 }
277 278
278} 279}