X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcopy.cpp;h=2d2a7ca9c023c557954e05924d9181f4280dae97;hb=bc85cc286c8a3f1055f1979a7ff8697cf1b61912;hp=c9cb3112ac25465d81ddf3a098eacbb5e46003ed;hpb=291455f435a4319ce3460e2e47d8f036222a3f92;p=builder.git diff --git a/source/copy.cpp b/source/copy.cpp index c9cb311..2d2a7ca 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -1,72 +1,83 @@ -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "builder.h" #include "copy.h" -#include "package.h" +#include "installedfile.h" using namespace std; using namespace Msp; -Copy::Copy(Builder &b, const Package &pkg, const Path::Path &s, const Path::Path &d): - Action(b), - src(s), - dest(d), - worker(*this) +Copy::Copy(Builder &b): + Tool(b, "CP") +{ } + +Target *Copy::create_target(const list &sources, const string &arg) { - announce(pkg.get_name(), "INST", dest[-1]); - if(builder.get_verbose()>=2) - cout< "<(*sources.front()); + InstalledFile *inst = new InstalledFile(builder, *file_tgt.get_package(), file_tgt, arg); + inst->set_tool(*this); + return inst; } -int Copy::check() +Task *Copy::run(const Target &target) const { - if(worker.get_done()) - { - signal_done.emit(); - worker.join(); - return worker.get_error()?1:0; - } - return -1; + const InstalledFile &install = dynamic_cast(target); + Worker *worker = new Worker(install); + InternalTask *task = new InternalTask(worker); + task->add_file(install.get_path()); + task->set_unlink(); + return task; } + +Copy::Worker::Worker(const InstalledFile &t): + target(t) +{ } + void Copy::Worker::main() { - Path::mkpath(copy.src.subpath(0, copy.src.size()-1), 0755); - if(unlink(copy.dest.str().c_str())<0 && errno!=ENOENT) - { - int err=errno; - cerr<<"Can't unlink "<