summaryrefslogtreecommitdiffabout
path: root/lib/file_factory.cc
authorMichael Krelin <hacker@klever.net>2005-01-29 21:21:05 (UTC)
committer Michael Krelin <hacker@klever.net>2005-01-29 21:21:05 (UTC)
commitce1f37aae46ea95020d7b865f7a80e8abdfad0d8 (patch) (side-by-side diff)
tree4964383ab8cd7e6d8ea821f1a615d1bbcf98dad8 /lib/file_factory.cc
parent3c75c860fc1ad5b3f5185e23ec6f438dd2528958 (diff)
downloadsitecing-0.0.zip
sitecing-0.0.tar.gz
sitecing-0.0.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'lib/file_factory.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/file_factory.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/file_factory.cc b/lib/file_factory.cc
new file mode 100644
index 0000000..c6b5748
--- a/dev/null
+++ b/lib/file_factory.cc
@@ -0,0 +1,55 @@
+#ifdef USE_PCH
+ #include "pch.h"
+#else
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <konforka/exception.h>
+ using namespace std;
+ #include "sitecing/file_factory.h"
+#endif
+
+namespace sitecing {
+
+ bool file_factory::is_uptodate(const string& dst,file_list_t* deps) {
+ file_list_t deplist;
+ file_list_t *fl = deps?deps:&deplist;
+ get_dependencies(dst,*fl);
+ struct stat stdst;
+ if(stat(dst.c_str(),&stdst))
+ return false;
+ for(file_list_t::const_iterator i=fl->begin();i!=fl->end();i++) {
+ struct stat stdep;
+ if(stat(i->c_str(),&stdep))
+ return false;
+ if(stdst.st_mtime<stdep.st_mtime)
+ return false;
+ if(!is_uptodate(*i))
+ return false;
+ }
+ return true;
+ }
+
+ void file_factory::make(const string& dst) {
+ try {
+ depth++;
+ if(depth>25)
+ throw konforka::exception(CODEPOINT,"recursed too deeply.");
+ file_list_t deps;
+ if(!is_uptodate(dst,&deps)) {
+ for(file_list_t::const_iterator i=deps.begin();i!=deps.end();i++)
+ make(*i);
+ build(dst);
+ }
+ depth--;
+ }catch(konforka::exception& ke) {
+ depth--;
+ ke.see(CODEPOINT);
+ throw;
+ }catch(...) {
+ depth--;
+ throw;
+ }
+ }
+
+}