X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcopy.cpp;h=24be942532b83ab52a0dcfdeb8446ad29d708edf;hb=71554f76b7ae8f1f9d183dc0c522655ce458cb78;hp=b756e0c037412012a828075735a7b6fb8eb3b679;hpb=8fa75f16e653e22f188bc09c5d04c3cdb5cf8c52;p=builder.git diff --git a/source/copy.cpp b/source/copy.cpp index b756e0c..24be942 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -16,11 +16,10 @@ Copy::Copy(Builder &b): Tool(b, "CP") { } -Target *Copy::create_target(const list &sources, const string &arg) const +Target *Copy::create_target(const list &sources, const string &arg) { FileTarget &file_tgt = dynamic_cast(*sources.front()); - const SourcePackage &pkg = dynamic_cast(*file_tgt.get_package()); - InstalledFile *inst = new InstalledFile(builder, pkg, file_tgt, arg); + InstalledFile *inst = new InstalledFile(builder, *file_tgt.get_package(), file_tgt, arg); inst->set_tool(*this); return inst; } @@ -35,9 +34,7 @@ Task *Copy::run(const Target &target) const Copy::Worker::Worker(const InstalledFile &t): target(t) -{ - launch(); -} +{ } void Copy::Worker::main() { @@ -90,6 +87,8 @@ void Copy::Worker::main() if(!link.empty()) { FS::Path relpath = FS::relative(dst_path, FS::dirname(link)); + if(FS::exists(link)) + FS::unlink(link); symlink(relpath.str().c_str(), link.str().c_str()); }