]> git.tdb.fi Git - builder.git/blob - source/filetarget.cpp
Make the name of a FileTarget be its basename instead of full path
[builder.git] / source / filetarget.cpp
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include <msp/fs/stat.h>
9 #include <msp/fs/utils.h>
10 #include "builder.h"
11 #include "filetarget.h"
12
13 using namespace std;
14 using namespace Msp;
15
16 FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
17         Target(b, p, FS::basename(a.str())),
18         path(a),
19         size(0)
20 {
21         builder.add_target(this);
22
23         struct stat st;
24         if(!FS::stat(path, st))
25         {
26                 mtime = Time::TimeStamp::from_unixtime(st.st_mtime);
27                 size = st.st_size;
28         }
29 }