X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdependencycache.cpp;h=b2ba4e8ce953e9b92bd41d4c66443bf24c749237;hb=7edb751727a176f58da886c2424d4840a0a910fd;hp=978a0e37b8ccb3bb96d7a56d43f0b9248fb3dbd2;hpb=39e1c3a79129a1718b5751c17a1cc6cc6903090e;p=builder.git diff --git a/source/dependencycache.cpp b/source/dependencycache.cpp index 978a0e3..b2ba4e8 100644 --- a/source/dependencycache.cpp +++ b/source/dependencycache.cpp @@ -5,8 +5,10 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include #include +#include +#include +#include #include #include "builder.h" #include "dependencycache.h" @@ -44,32 +46,34 @@ void DependencyCache::save() const if(deps.empty() || !changed || package.get_builder().get_dry_run()) return; - ofstream out((package.get_source()/".deps").str().c_str()); - if(!out) - return; + IO::BufferedFile out((package.get_source()/".deps").str(), IO::M_WRITE); for(DepsMap::const_iterator i=deps.begin(); i!=deps.end(); ++i) { - out<first; + IO::print(out, i->first); for(StringList::const_iterator j=i->second.begin(); j!=i->second.end(); ++j) - out<<'|'<<*j; - out<<'\n'; + IO::print(out, "|%s", *j); + IO::print(out, "\n"); } } void DependencyCache::load() { string fn=(package.get_source()/".deps").str(); - ifstream in(fn.c_str()); - if(!in) - return; - string line; - while(getline(in, line)) + try { - vector parts=split(line, '|'); - deps[parts[0]]=StringList(parts.begin()+1, parts.end()); - } + IO::BufferedFile in(fn); - mtime=Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime); + string line; + while(in.getline(line)) + { + vector parts=split(line, '|'); + deps[parts[0]]=StringList(parts.begin()+1, parts.end()); + } + + mtime=Time::TimeStamp::from_unixtime(FS::stat(fn).st_mtime); + } + catch(const IO::FileNotFound &) + { } }