mirror of
https://github.com/matrix-construct/construct
synced 2025-03-17 06:50:23 +01:00
ircd::mods: Add unpostfixed() and postfixed() for module names.
This commit is contained in:
parent
fe5614387e
commit
5fe03e5c0a
2 changed files with 25 additions and 2 deletions
|
@ -129,6 +129,9 @@ struct import_shared
|
|||
import_shared(const std::string &modname, const std::string &symname);
|
||||
};
|
||||
|
||||
std::string postfixed(const std::string &name);
|
||||
std::string unpostfixed(const std::string &name);
|
||||
|
||||
std::vector<std::string> symbols(const std::string &fullpath, const std::string §ion);
|
||||
std::vector<std::string> symbols(const std::string &fullpath);
|
||||
std::vector<std::string> sections(const std::string &fullpath);
|
||||
|
|
24
ircd/mods.cc
24
ircd/mods.cc
|
@ -70,9 +70,16 @@ struct mod
|
|||
~mod() noexcept;
|
||||
};
|
||||
|
||||
static const auto suffix
|
||||
{
|
||||
boost::dll::shared_library::suffix()
|
||||
};
|
||||
|
||||
filesystem::path prefix_if_relative(const filesystem::path &path);
|
||||
filesystem::path postfixed(const filesystem::path &path);
|
||||
filesystem::path unpostfixed(const filesystem::path &path);
|
||||
std::string postfixed(const std::string &name);
|
||||
std::string unpostfixed(const std::string &name);
|
||||
|
||||
template<class R, class F> R info(const filesystem::path &, F&& closure);
|
||||
std::vector<std::string> sections(const filesystem::path &path);
|
||||
|
@ -538,17 +545,30 @@ const
|
|||
return std::find(begin(), end(), dir) != end();
|
||||
}
|
||||
|
||||
std::string
|
||||
ircd::mods::unpostfixed(const std::string &name)
|
||||
{
|
||||
return unpostfixed(filesystem::path(name)).string();
|
||||
}
|
||||
|
||||
std::string
|
||||
ircd::mods::postfixed(const std::string &name)
|
||||
{
|
||||
return postfixed(filesystem::path(name)).string();
|
||||
}
|
||||
|
||||
filesystem::path
|
||||
ircd::mods::unpostfixed(const filesystem::path &path)
|
||||
{
|
||||
if(extension(path) != suffix)
|
||||
return path;
|
||||
|
||||
return filesystem::path(path).replace_extension();
|
||||
}
|
||||
|
||||
filesystem::path
|
||||
ircd::mods::postfixed(const filesystem::path &path)
|
||||
{
|
||||
static const auto suffix(boost::dll::shared_library::suffix());
|
||||
|
||||
if(extension(path) == suffix)
|
||||
return path;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue