--- /dev/null
+#include <msp/fs/utils.h>
+#include "filetarget.h"
+#include "installmap.h"
+
+using namespace std;
+using namespace Msp;
+
+void InstallMap::add_mapping(const FS::Path &src, const FS::Path &inst)
+{
+ Entry e;
+ e.source = src;
+ e.install = inst;
+ entries.push_back(e);
+}
+
+FS::Path InstallMap::get_install_location(const FileTarget &target) const
+{
+ const FS::Path &source = target.get_path();
+ FS::Path install = target.get_install_location();
+ for(list<Entry>::const_iterator i=entries.begin(); i!=entries.end(); ++i)
+ {
+ int source_depth = FS::descendant_depth(source, i->source);
+ if(source_depth>=0)
+ {
+ FS::Path install_base = FS::common_ancestor(install, i->install);
+ if(install_base.size()>1)
+ {
+ install = i->install/FS::dirname(source).subpath(i->source.size());
+ break;
+ }
+ }
+ }
+
+ return install;
+}
+
+
+InstallMap::Loader::Loader(InstallMap &m, const FS::Path &s):
+ DataFile::ObjectLoader<InstallMap>(m),
+ source_base(s)
+{
+ add("map", &Loader::map);
+}
+
+void InstallMap::Loader::map(const string &src, const string &inst)
+{
+ obj.add_mapping(source_base/src, inst);
+}