16 #include <zypp-core/APIConfig.h> 58 if ( configStem.relative() ) {
59 if ( configStem.relativeDotDot() )
61 configStem = configStem.absolutename();
63 if ( configStem.emptyOrRoot() )
65 pMIL(
"getConfigFiles for stem", configStem,
"below", root_r,
"in",
_etcDir,
_usrDir );
67 std::string configSuffix { configStem.
extension() };
70 std::vector<Pathname> lookupDirs;
79 std::map<std::string,PathInfo> dropinsToParse;
81 for (
const Pathname & ldir : lookupDirs ) {
83 PathInfo basecfg { ldir / configStem };
87 PathInfo dropinDir { ldir / configDir };
88 if ( dropinDir.isDir() ) {
90 if ( entry.name[0] ==
'.' )
92 if ( not ( configSuffix.empty() ||
str::hasSuffix( entry.name, configSuffix ) ) )
95 takeOrMask( dropin, dropinsToParse[entry.name] );
102 std::vector<Pathname> ret;
104 for (
const auto & [
_,p] : dropinsToParse ) {
109 pMIL(
"No config files found for stem", configStem,
"below", root_r );
118 lookupDirs_r.push_back( dir_r );
129 if (
isSet( toParse_r ) ) {
130 pDBG(
"masked", file_r,
"by", toParse_r );
132 toParse_r = std::move(file_r);
140 if (
isSet( file_r ) ) {
141 pMIL(
"take", file_r );
142 ret_r.push_back( file_r.
path() );
165 pDBG( stem_r,
"below", root_r,
":", *
this );
Listentry returned by readdir.
const Pathname & path() const
Return current Pathname.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static void takeLookupDirIf(std::vector< Pathname > &lookupDirs_r, Pathname dir_r)
Remember valid lookup dirs.
const std::optional< Pathname > & etcDir() const
static void takeOrMask(const PathInfo &file_r, PathInfo &toParse_r)
The 1st viable file_r is stored in toParse_r; candidates found later are masked.
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
Provide access to the prioritized list of files and drop-ins to read and merge for a specific config ...
void read(const InputStream &is, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Fill a dictionary from a InputStream containing a ini structured file.
static bool isSet(const PathInfo &file_r)
An empty path denotes the unset value.
std::optional< Pathname > _etcDir
system configuration: /etc
bool empty() const
Test for an empty path.
bool isExist() const
Return whether valid stat info exists.
static Pathname _defaultDistconfDir
APIConfig(LIBZYPP_ZYPPCONFDIR) but amendable for Testing.
std::optional< Pathname > _usrDir
vendor configuration: distconfdir (APIConfig(LIBZYPP_ZYPPCONFDIR))
static void handOutIf(std::vector< Pathname > &ret_r, const PathInfo &file_r)
Store set values in ret_r.
static Pathname defaultDistconfDir()
Where the vendor configuration files live (APIConfig(LIBZYPP_ZYPPCONFDIR))
const std::optional< Pathname > & usrDir() const
ConfigurationContext(std::optional< Pathname > etcDir_r, std::optional< Pathname > usrDir_r)
Parses a INI file and offers its structure as a dictionary.
bool hasSuffix(const C_Str &str_r, const C_Str &suffix_r)
Return whether str_r has suffix suffix_r.
std::vector< Pathname > getConfigFiles(const std::string &stem_r, const Pathname &root_r=Pathname("/")) const
Wrapper class for ::stat/::lstat.
int dirForEachExt(const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r)
Simiar to.
std::string sprint(Args &&... args)
Print words as string.
std::string extension() const
Return all of the characters in name after and including the last dot in the last element of name...