]> git.tdb.fi Git - builder.git/blob - source/task.cpp
Use default member initializers and constructor delegation
[builder.git] / source / task.cpp
1 #include <msp/fs/dir.h>
2 #include <msp/fs/stat.h>
3 #include <msp/fs/utils.h>
4 #include "task.h"
5
6 using namespace std;
7 using namespace Msp;
8
9 void Task::add_file(const FS::Path &f)
10 {
11         files.push_back(f);
12 }
13
14 void Task::set_unlink(bool u)
15 {
16         unlink = u;
17 }
18
19 void Task::prepare()
20 {
21         for(const FS::Path &f: files)
22         {
23                 if(FS::exists(f))
24                 {
25                         // If the file exists, the directory it's in must exist too
26                         FS::unlink(f);
27                 }
28                 else
29                 {
30                         FS::Path dir = FS::dirname(f);
31                         if(!FS::exists(dir))
32                                 FS::mkpath(dir, 0755);
33                 }
34         }
35 }