X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftar.cpp;h=6f7b154feabba71b738c66623080d4d02b68c1a6;hb=3aad704c2d2fac737424a0a2697874927bd95c37;hp=bd29aafc56543547a0f91c5b360398aae2546e48;hpb=ab25857fd626152bc9a2832de82b400c062857e6;p=builder.git diff --git a/source/tar.cpp b/source/tar.cpp index bd29aaf..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" @@ -19,7 +22,7 @@ Tar::Tar(Builder &b, const TarBall &t): 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_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); @@ -74,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