#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
+#include <msp/time/utils.h>
+#include "filetarget.h"
#include "task.h"
using namespace std;
using namespace Msp;
-void Task::add_file(const FS::Path &f)
+void Task::add_target(const FileTarget &t)
{
- files.push_back(f);
+ targets.push_back(&t);
}
void Task::set_unlink(bool u)
void Task::prepare()
{
- for(const FS::Path &f: files)
+ start_time = Time::now();
+
+ for(const FileTarget *t: targets)
{
+ const FS::Path &f = t->get_path();
if(FS::exists(f))
{
// If the file exists, the directory it's in must exist too
}
}
}
+
+void Task::finished(bool success)
+{
+ if(!duration && start_time)
+ duration = Time::now()-start_time;
+ signal_finished.emit(success);
+}