]> git.tdb.fi Git - builder.git/blobdiff - source/config.cpp
Migrate from msppath to mspfs
[builder.git] / source / config.cpp
index 816ee1abb0ea26140625d9ec13dacc518dc4987a..fbb36ac3d5cc32b1e3bec7fb63b917cc3879ab03 100644 (file)
@@ -5,11 +5,13 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <cstdlib>
 #include <msp/core/except.h>
+#include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
 #include <msp/io/except.h>
 #include <msp/io/file.h>
 #include <msp/io/print.h>
-#include <msp/path/utils.h>
 #include <msp/time/utils.h>
 #include "builder.h"
 #include "config.h"
@@ -150,15 +152,17 @@ void Config::finish()
                                }
                                else
                                {
-                                       for(end=dollar+1; (isalnum(opt.value[end]) && opt.value[end]!='_'); ++end);
+                                       for(end=dollar+1; (isalnum(opt.value[end]) && opt.value[end]!='_'); ++end) ;
                                        var=opt.value.substr(dollar+1, end-dollar-1);
                                }
 
                                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);
 
@@ -174,7 +178,7 @@ void Config::finish()
 
 void Config::save() const
 {
-       Path fn=package.get_source()/".options.cache";
+       FS::Path fn=package.get_source()/".options.cache";
 
        OptionMap::const_iterator i=options.find("profile");
        if(i!=options.end())
@@ -203,7 +207,7 @@ bool Config::set_option(const string &opt, const string &val)
 
 void Config::load()
 {
-       Path fn=package.get_source()/".options.cache";
+       FS::Path fn=package.get_source()/".options.cache";
 
        OptionMap::iterator i=options.find("profile");
        if(i!=options.end())
@@ -211,15 +215,16 @@ 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);
+               mtime=Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime);
 
                DataFile::Parser parser(in, fn.str());
                Loader loader(*this);
                loader.load(parser);
        }
-       catch(const SystemError &)
+       catch(const IO::FileNotFound &)
        { }
 }