]> git.tdb.fi Git - builder.git/blob - source/makesymlink.cpp
b7f64de623e9e59b88e23f7039589ffb638b2e38
[builder.git] / source / makesymlink.cpp
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include <unistd.h>
9 #include <msp/fs/utils.h>
10 #include <msp/io/print.h>
11 #include "builder.h"
12 #include "package.h"
13 #include "makesymlink.h"
14 #include "symlink.h"
15
16 using namespace Msp;
17
18 MakeSymlink::MakeSymlink(Builder &b, const Symlink &sl):
19         Action(b)
20 {
21         FS::Path relpath = FS::relative(sl.get_target().get_path(), FS::dirname(sl.get_path()));
22
23         announce(sl.get_package()->get_name(), "LN", sl.get_path().str());
24         if(builder.get_verbose()>=2)
25                 IO::print("%s -> %s\n", sl.get_name(), relpath.str());
26
27         if(!builder.get_dry_run())
28                 symlink(relpath.str().c_str(), sl.get_path().str().c_str());
29 }
30
31 int MakeSymlink::check()
32 {
33         signal_done.emit();
34         return 0;
35 }