]> git.tdb.fi Git - builder.git/blobdiff - source/config.cpp
Drop the .cache suffix when saving config too
[builder.git] / source / config.cpp
index 4cc9149efe6deb4f672e29e0cfc5ed9e01f4a525..da63cc9464f3de13756673db1a8c8c6181f9c9ab 100644 (file)
@@ -7,10 +7,11 @@ 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"
@@ -65,7 +66,7 @@ void Config::select_last_profile()
 {
        try
        {
-               IO::File in((package.get_source()/".profile.cache").str());
+               IO::BufferedFile in((package.get_source()/".profile").str());
                string profile;
                in.getline(profile);
                set_option("profile", profile);
@@ -90,7 +91,7 @@ void Config::select_profile(const string &profile)
 
        if(!package.get_builder().get_dry_run())
        {
-               IO::File out((package.get_source()/".profile.cache").str(), IO::M_WRITE);
+               IO::BufferedFile out((package.get_source()/".profile").str(), IO::M_WRITE);
                IO::print(out, "%s\n", profile);
        }
 
@@ -177,13 +178,13 @@ void Config::finish()
 
 void Config::save() const
 {
-       Path fn=package.get_source()/".options.cache";
+       FS::Path fn=package.get_source()/".options";
 
        OptionMap::const_iterator i=options.find("profile");
        if(i!=options.end())
-               fn=package.get_source()/(".options."+i->second.value+".cache");
+               fn=package.get_source()/(".options."+i->second.value);
 
-       IO::File out(fn.str(), IO::M_WRITE);
+       IO::BufferedFile 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);
@@ -206,18 +207,13 @@ bool Config::set_option(const string &opt, const string &val)
 
 void Config::load()
 {
-       Path fn=package.get_source()/".options.cache";
-
-       OptionMap::iterator i=options.find("profile");
-       if(i!=options.end())
-               fn=package.get_source()/(".options."+i->second.value+".cache");
+       FS::Path fn=package.get_source()/(".options."+get_option("profile").value);
 
        try
        {
-               IO::File inf(fn.str());
-               IO::Buffered in(inf);
+               IO::BufferedFile in(fn.str());
 
-               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);