1 #include <msp/fs/utils.h>
3 #include "filetarget.h"
4 #include "installmap.h"
9 void InstallMap::add_mapping(const FS::Path &src, const FS::Path &inst)
17 FS::Path InstallMap::get_install_location(const FileTarget &target) const
19 const Component *comp = target.get_component();
20 unsigned overlay_depth = 0;
21 if(comp && !comp->get_overlays().empty())
23 const Component::OverlayList &overlays = comp->get_overlays();
24 string last_dir = FS::basename(FS::dirname(target.get_path()));
25 for(Component::OverlayList::const_iterator i=overlays.begin(); i!=overlays.end(); ++i)
30 const FS::Path &source = target.get_path();
31 FS::Path install = target.get_install_location();
32 for(list<Entry>::const_iterator i=entries.begin(); i!=entries.end(); ++i)
34 int source_depth = FS::descendant_depth(source, i->source);
37 FS::Path install_base = FS::common_ancestor(install, i->install);
38 if(install_base.size()>1)
40 install = i->install/source.subpath(i->source.size(), source_depth-1-overlay_depth);
50 InstallMap::Loader::Loader(InstallMap &m, const FS::Path &s):
51 DataFile::ObjectLoader<InstallMap>(m),
54 add("map", &Loader::map);
57 void InstallMap::Loader::map(const string &src, const string &inst)
59 obj.add_mapping(source_base/src, inst);