From fb28f6800864176be2ffca29e8e664b641f33170 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Dec 2009 18:04:02 +0000 Subject: m3 is copied into trunk, we should be good to go, now. --- src/conditionfiletime.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/conditionfiletime.cpp (limited to 'src/conditionfiletime.cpp') diff --git a/src/conditionfiletime.cpp b/src/conditionfiletime.cpp new file mode 100644 index 0000000..224caf1 --- /dev/null +++ b/src/conditionfiletime.cpp @@ -0,0 +1,73 @@ +#include "conditionfiletime.h" +#include "target.h" + +#include +#include +#include + +#include +using namespace Bu; + +ConditionFileTime::ConditionFileTime() +{ +} + +ConditionFileTime::~ConditionFileTime() +{ +} + +bool ConditionFileTime::shouldExec( class Runner &r, Target &rTarget ) +{ + for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ ) + { + if( access( (*j).getStr(), F_OK ) ) + { + //sio << "-- Target processed because '" << *j << "' doesn't exist." + // << sio.nl; + // Output doesn't exist + return true; + } + } + + time_t tOut = 0; + struct stat s; + for( StrList::const_iterator j = rTarget.getOutputList().begin(); + j; j++ ) + { + stat( (*j).getStr(), &s ); + if( tOut == 0 || tOut > s.st_mtime ) + { + tOut = s.st_mtime; + } + } + for( StrList::const_iterator j = rTarget.getInputList().begin(); + j; j++ ) + { + stat( (*j).getStr(), &s ); + if( tOut < s.st_mtime ) + { + //sio << "-- Target processed because '" << *j + // << "' is newer than output." << sio.nl; + return true; + } + } + rTarget.buildRequires( r ); + for( StrList::const_iterator j = rTarget.getRequiresList().begin(); + j; j++ ) + { + stat( (*j).getStr(), &s ); + if( tOut < s.st_mtime ) + { + //sio << "-- Target processed because '" << *j + // << "' is newer than output." << sio.nl; + return true; + } + } + return false; +} + +Condition *ConditionFileTime::clone() +{ + return new ConditionFileTime(); +} + -- cgit v1.2.3