// // aegis - project change supervisor // Copyright (C) 2014 Peter Miller // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or (at // your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program. If not, see . // #include #include iformat_tar::~iformat_tar() { trace(("%s\n", __PRETTY_FUNCTION__)); } iformat_tar::iformat_tar(const input::pointer &a_deeper) : iformat(a_deeper), itar_p(input_tar::create(a_deeper)) { trace(("%s\n", __PRETTY_FUNCTION__)); } iformat::pointer iformat_tar::create(const input::pointer &a_deeper) { trace(("%s\n", __PRETTY_FUNCTION__)); return pointer(new iformat_tar(a_deeper)); } bool iformat_tar::candidate(const input::pointer &ip) { return input_tar::candidate(ip); } iformat::token_t iformat_tar::get_token_inner(nstring &name, input::pointer &value) { trace(("%s\n", __PRETTY_FUNCTION__)); nstring member_name; bool exec = false; value = itar_p->child(member_name, exec); if (!value) return token_eof; trace(("member_name = %s\n", member_name.quote_c().c_str())); // discard leading slashes (no absolute pathnames). { size_t n = 0; while (n < member_name.size()) { if (n < member_name.size() && member_name[n] == '/') { ++n; continue; } if ( n + 1 < member_name.size() && member_name[n] == '.' && member_name[n + 1] == '/' ) { n += 2; continue; } break; } if (n) { member_name = member_name.substr(n, member_name.size() - n); trace(("member_name = %s\n", member_name.quote_c().c_str())); } } // categorize he file names into tokens. if (member_name == "...aegis/project-name") return token_project_name; if (member_name == "...aegis/change-number") return token_project_name; if (member_name == "...aegis/meta-data.txt") return token_meta_data; if (member_name.starts_with("...aegis/partition")) return token_partition; if (member_name.starts_with("...aegis/patch/")) { name = member_name.substr(15, member_name.size() - 15); return token_patch; } if (member_name.starts_with("...aegis/")) { fatal_error ( "mystery %s tar archive member", member_name.quote_c().c_str() ); } // Don't worry about removing path prefixes, we will use a filter // for that (the filter also applies to patch filenames). name = member_name; return token_source; } // vim: set ts=8 sw=4 et :