--- /dev/null
+#include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
+#include "task.h"
+
+using namespace Msp;
+
+Task::Task():
+ unlink(false)
+{ }
+
+void Task::set_file(const FS::Path &f)
+{
+ file = f;
+}
+
+void Task::set_unlink(bool u)
+{
+ unlink = u;
+}
+
+void Task::prepare()
+{
+ if(!file.empty())
+ {
+ if(FS::exists(file))
+ {
+ // If the file exists, the directory it's in must exist too
+ FS::unlink(file);
+ }
+ else
+ {
+ FS::Path dir = FS::dirname(file);
+ if(!FS::exists(dir))
+ FS::mkpath(dir, 0755);
+ }
+ }
+}