//
// aegis - project change supervisor
// Copyright (C) 2001, 2002, 2004-2008, 2012, 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
#include
#include
#include
#include
#include
#include
format::~format()
{
}
format::format()
{
}
struct context_t:
public dir_functor
{
virtual ~context_t() { fp = NULL; base.clear(); fslp = NULL; }
context_t() : fp(0), base("."), fslp(NULL) { }
format *fp;
nstring base;
format_search_list *fslp;
void operator()(dir_functor::msg_t msg, const nstring &filename,
const struct stat &st);
};
void
context_t::operator()(dir_functor::msg_t msg, const nstring &filename,
const struct stat &)
{
switch (msg)
{
case dir_functor::msg_file:
if (fp->is_a_candidate(filename))
{
nstring relative = os_below_dir(base, filename);
nstring sanitized = fp->sanitize(relative, true);
format_version *fvp = NULL;
if (sanitized != THE_CONFIG_FILE_OLD &&
sanitized != THE_CONFIG_FILE_NEW)
{
fvp = fp->read_versions(filename, sanitized);
}
format_search_ty *fsp = format_search_new();
fsp->filename_physical = filename;
fsp->filename_logical = sanitized;
fsp->root = fvp;
fslp->append(fsp);
}
break;
case dir_functor::msg_dir_before:
case dir_functor::msg_dir_after:
case dir_functor::msg_special:
case dir_functor::msg_symlink:
break;
default:
assert(!"case not handled in switch");
break;
}
}
format_search_list *
format::search(const nstring &base)
{
context_t context;
context.fp = this;
context.base = base;
context.fslp = new format_search_list();
dir_walk(base, context);
return context.fslp;
}
nstring
format::history_put(void)
{
return nstring();
}
nstring
format::history_get(void)
{
assert(!"derived classes must override history_get");
return nstring();
}
nstring
format::history_query(void)
{
assert(!"derived classes must override history_query");
return nstring();
}
nstring
format::diff(void)
{
assert(!"derived classes must override diff");
return "exit 0";
}
nstring
format::merge(void)
{
assert(!"derived classes must override merge");
return nstring();
}
void
format::unlock(const nstring &)
{
assert(!"derived classes must override unlock");
}
nstring
format::sanitize(const nstring &, bool)
{
assert(!"derived classes must override sanitize");
return nstring();
}
bool
format::valid(void)
const
{
return true;
}
// vim: set ts=8 sw=4 et :