X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftar.cpp;h=6f7b154feabba71b738c66623080d4d02b68c1a6;hb=3aad704c2d2fac737424a0a2697874927bd95c37;hp=0b0c38df775696fcf1e98d8333a3357df68af305;hpb=555190f7eafcf3a67750fc63872b23e17371aa98;p=builder.git diff --git a/source/tar.cpp b/source/tar.cpp index 0b0c38d..6f7b154 100644 --- a/source/tar.cpp +++ b/source/tar.cpp @@ -1,14 +1,17 @@ /* $Id$ This file is part of builder -Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ #include -#include +#include +#include +#include +#include #include "builder.h" -#include "package.h" +#include "sourcepackage.h" #include "tar.h" #include "tarball.h" @@ -16,64 +19,42 @@ using namespace std; using namespace Msp; Tar::Tar(Builder &b, const TarBall &t): - Action(b), - tarball(t), - worker(0) + InternalAction(b), + tarball(t) { - string basename=tarball.get_name().substr(tarball.get_name().rfind('/')+1); + string basename=FS::basename(tarball.get_path()); announce(tarball.get_package()->get_name(), "TAR ", basename); if(builder.get_verbose()>=2) cout<<"Create "<get_done()) - { - signal_done.emit(); - worker->join(); - return worker->get_error()?1:0; - } - - return -1; -} - Tar::Worker::Worker(Tar &t): - tar(t), - done(false), - error(false) + tar(t) { launch(); } void Tar::Worker::main() { - const Path::Path &pkg_src=tar.tarball.get_package()->get_source(); - Path::Path basedir=Path::splitext(Path::basename(tar.tarball.get_name())).base; + const FS::Path &pkg_src=tar.tarball.get_package()->get_source(); + FS::Path basedir=FS::basepart(FS::basename(tar.tarball.get_path())); - ofstream out(tar.tarball.get_name().c_str()); + IO::File out(tar.tarball.get_path().str(), IO::M_WRITE); const TargetList &deps=tar.tarball.get_depends(); for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) { + FileTarget *ft=dynamic_cast(*i); + if(!ft) + continue; + char buf[4096]; memset(buf, 0, 512); - string rel_path=(basedir/relative((*i)->get_name(), pkg_src)).str(); + string rel_path=(basedir/relative(ft->get_path(), pkg_src)).str(); if(rel_path.size()>99) { cout<<"Can't store "<get_name(), st); + struct stat st=FS::stat(ft->get_path()); store_number(buf+100, st.st_mode, 7); store_number(buf+108, st.st_uid, 7); store_number(buf+116, st.st_gid, 7); @@ -100,11 +80,10 @@ void Tar::Worker::main() buf[155]=0; out.write(buf, 512); - ifstream in((*i)->get_name().c_str()); + IO::File in(ft->get_path().str()); for(int j=0; j