]> git.tdb.fi Git - builder.git/blobdiff - source/copy.cpp
Remove some useless member functions
[builder.git] / source / copy.cpp
index b756e0c037412012a828075735a7b6fb8eb3b679..75d047df7ef50c6371835f456a747f2c34b6121a 100644 (file)
@@ -1,4 +1,4 @@
-#include <errno.h>
+#include <unistd.h>
 #include <sys/stat.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
@@ -19,8 +19,7 @@ Copy::Copy(Builder &b):
 Target *Copy::create_target(const list<Target *> &sources, const string &arg) const
 {
        FileTarget &file_tgt = dynamic_cast<FileTarget &>(*sources.front());
-       const SourcePackage &pkg = dynamic_cast<const SourcePackage &>(*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());
        }