X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fconfig.cpp;h=753a4ef65b0577dca6bf0301290898461cd188de;hb=0f5283a54fd188072eca23fbd980a43c6c869913;hp=c8e9aaa7e57623a9506c3e248c8e11a21d73b810;hpb=b3b2a8666defb9e1a5937bcfefc1bc8e02793aab;p=builder.git diff --git a/source/config.cpp b/source/config.cpp index c8e9aaa..753a4ef 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -6,6 +6,7 @@ Distributed under the LGPL */ #include +#include #include #include #include @@ -68,7 +69,7 @@ void Config::select_last_profile() in.getline(profile); set_option("profile", profile); } - catch(const SystemError &) + catch(const IO::FileNotFound &) { } freeze_mtime=true; @@ -88,13 +89,8 @@ void Config::select_profile(const string &profile) if(!package.get_builder().get_dry_run()) { - try - { - IO::File out((package.get_source()/".profile.cache").str().c_str()); - IO::print(out, "%s\n", profile); - } - catch(const SystemError &) - { } + IO::File out((package.get_source()/".profile.cache").str(), IO::M_WRITE); + IO::print(out, "%s\n", profile); } freeze_mtime=true; @@ -161,8 +157,10 @@ void Config::finish() string value; if(is_option(var)) value=get_option(var).value; - else - value=getenv(var.c_str()); + else if(var=="arch") + value=package.get_builder().get_current_arch().get_name(); + else if(const char *ptr=getenv(var.c_str())) + value=ptr; opt.value.replace(dollar, end-dollar, value); @@ -184,15 +182,10 @@ void Config::save() const if(i!=options.end()) fn=package.get_source()/(".options."+i->second.value+".cache"); - try - { - IO::File out(fn.str()); + IO::File out(fn.str(), IO::M_WRITE); - for(i=options.begin(); i!=options.end(); ++i) - IO::print(out, "option \"%s\" \"%s\";\n", i->second.name, i->second.value); - } - catch(const SystemError &) - { } + for(i=options.begin(); i!=options.end(); ++i) + IO::print(out, "option \"%s\" \"%s\";\n", i->second.name, i->second.value); } bool Config::set_option(const string &opt, const string &val) @@ -220,7 +213,8 @@ void Config::load() try { - IO::File in(fn.str()); + IO::File inf(fn.str()); + IO::Buffered in(inf); mtime=Time::TimeStamp::from_unixtime(stat(fn).st_mtime); @@ -228,7 +222,7 @@ void Config::load() Loader loader(*this); loader.load(parser); } - catch(const SystemError &) + catch(const IO::FileNotFound &) { } }