aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/file_suffixes.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-18 22:44:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-18 22:48:57 +0000
commitbdf2d8a162a597af3a758e84e68c5f65ce088ef3 (patch)
treec079bf31cb6af8203dd572069dddcc0d293f394e /paludis/repositories/e/file_suffixes.cc
parent48c9c785ecd6a96f056b9ecefb6df980967dda22 (diff)
downloadpaludis-bdf2d8a162a597af3a758e84e68c5f65ce088ef3.tar.gz
paludis-bdf2d8a162a597af3a758e84e68c5f65ce088ef3.tar.xz
Split out helpers
Diffstat (limited to 'paludis/repositories/e/file_suffixes.cc')
-rw-r--r--paludis/repositories/e/file_suffixes.cc50
1 files changed, 47 insertions, 3 deletions
diff --git a/paludis/repositories/e/file_suffixes.cc b/paludis/repositories/e/file_suffixes.cc
index cf6a61abd..c6d88b097 100644
--- a/paludis/repositories/e/file_suffixes.cc
+++ b/paludis/repositories/e/file_suffixes.cc
@@ -25,6 +25,7 @@
#include <paludis/util/fs_path.hh>
#include <paludis/util/log.hh>
#include <paludis/util/options.hh>
+#include <paludis/name.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -57,13 +58,24 @@ FileSuffixes::is_known_suffix(const std::string & s) const
return ! _imp->file.get("suffix_" + s + "_known").empty();
}
-std::string
-FileSuffixes::guess_eapi(const std::string & s) const
+const std::string
+FileSuffixes::guess_eapi_without_hint(const std::string & s) const
{
return _imp->file.get("guess_eapi_" + s);
}
-std::string
+const std::string
+FileSuffixes::guess_eapi_from_filename(const QualifiedPackageName &, const FSPath & e) const
+{
+ std::string::size_type p(e.basename().rfind('.'));
+ if (std::string::npos == p)
+ return "";
+
+ std::string suffix(e.basename().substr(p + 1));
+ return guess_eapi_without_hint(suffix);
+}
+
+const std::string
FileSuffixes::manifest_key(const std::string & s) const
{
std::string result(_imp->file.get("manifest_key_" + s));
@@ -77,3 +89,35 @@ FileSuffixes::manifest_key(const std::string & s) const
return result;
}
+bool
+FileSuffixes::is_package_file(const QualifiedPackageName & n, const FSPath & e) const
+{
+ Context context("When working out whether '" + stringify(e) + "' is a package file for '" + stringify(n) + "':");
+
+ if (0 != e.basename().compare(0, stringify(n.package()).length() + 1, stringify(n.package()) + "-"))
+ return false;
+
+ std::string::size_type p(e.basename().rfind('.'));
+ if (std::string::npos == p)
+ return false;
+
+ std::string suffix(e.basename().substr(p + 1));
+ return is_known_suffix(suffix);
+}
+
+const std::string
+FileSuffixes::get_package_file_manifest_key(const FSPath & e, const QualifiedPackageName & q) const
+{
+ if (! is_package_file(q, e))
+ return "";
+
+ std::string::size_type p(e.basename().rfind('.'));
+ if (std::string::npos == p)
+ return "EBUILD";
+
+ std::string suffix(e.basename().substr(p + 1));
+ return manifest_key(suffix);
+}
+
+template class Singleton<FileSuffixes>;
+