indents + use range-base for loops in extrameta.cpp
This commit is contained in:
parent
9e0018034c
commit
20c3a7ed12
@ -33,8 +33,7 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
|
||||
const string &value, Rcl::Doc& doc)
|
||||
{
|
||||
string fieldname = cfg->fieldCanon(name);
|
||||
LOGDEB0("Internfile:: setting [" << fieldname <<
|
||||
"] from cmd/xattr value [" << value << "]\n");
|
||||
LOGDEB0("Internfile:: setting [" << fieldname << "] from cmd/xattr value [" << value << "]\n");
|
||||
if (fieldname == cstr_dj_keymd) {
|
||||
doc.dmtime = value;
|
||||
} else {
|
||||
@ -42,8 +41,7 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
|
||||
}
|
||||
}
|
||||
|
||||
void reapXAttrs(const RclConfig* cfg, const string& path,
|
||||
map<string, string>& xfields)
|
||||
void reapXAttrs(const RclConfig* cfg, const string& path, map<string, string>& xfields)
|
||||
{
|
||||
LOGDEB2("reapXAttrs: [" << path << "]\n");
|
||||
#ifndef _WIN32
|
||||
@ -51,11 +49,9 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
||||
vector<string> xnames;
|
||||
if (!pxattr::list(path, &xnames)) {
|
||||
if (errno == ENOTSUP) {
|
||||
LOGDEB("FileInterner::reapXattrs: pxattr::list: errno " <<
|
||||
errno << "\n");
|
||||
LOGDEB("FileInterner::reapXattrs: pxattr::list: errno " << errno << "\n");
|
||||
} else {
|
||||
LOGERR("FileInterner::reapXattrs: pxattr::list: errno " <<
|
||||
errno << "\n");
|
||||
LOGSYSERR("FileInterner::reapXattrs", "pxattr::list", path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -64,10 +60,9 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
||||
// Record the xattrs: names found in the config are either skipped
|
||||
// or mapped depending if the translation is empty. Other names
|
||||
// are recorded as-is
|
||||
for (vector<string>::const_iterator it = xnames.begin();
|
||||
it != xnames.end(); it++) {
|
||||
string key = *it;
|
||||
map<string, string>::const_iterator mit = xtof.find(*it);
|
||||
for (const auto& xkey : xnames) {
|
||||
string key = xkey;
|
||||
auto mit = xtof.find(xkey);
|
||||
if (mit != xtof.end()) {
|
||||
if (mit->second.empty()) {
|
||||
continue;
|
||||
@ -76,9 +71,8 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
||||
}
|
||||
}
|
||||
string value;
|
||||
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
|
||||
LOGERR("FileInterner::reapXattrs: pxattr::get failed for " << *it
|
||||
<< ", errno " << errno << "\n");
|
||||
if (!pxattr::get(path, xkey, &value, pxattr::PXATTR_NOFOLLOW)) {
|
||||
LOGSYSERR("FileInterner::reapXattrs", "pxattr::get", path + " : " + xkey);
|
||||
continue;
|
||||
}
|
||||
// Encode should we ?
|
||||
@ -92,34 +86,29 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
|
||||
#endif
|
||||
}
|
||||
|
||||
void docFieldsFromXattrs(RclConfig *cfg, const map<string, string>& xfields,
|
||||
Rcl::Doc& doc)
|
||||
void docFieldsFromXattrs(RclConfig *cfg, const map<string, string>& xfields, Rcl::Doc& doc)
|
||||
{
|
||||
for (map<string,string>::const_iterator it = xfields.begin();
|
||||
it != xfields.end(); it++) {
|
||||
docfieldfrommeta(cfg, it->first, it->second, doc);
|
||||
for (const auto& fld : xfields) {
|
||||
docfieldfrommeta(cfg, fld.first, fld.second, doc);
|
||||
}
|
||||
}
|
||||
|
||||
void reapMetaCmds(RclConfig* cfg, const string& path,
|
||||
map<string, string>& cfields)
|
||||
void reapMetaCmds(RclConfig* cfg, const string& path, map<string, string>& cfields)
|
||||
{
|
||||
const vector<MDReaper>& reapers = cfg->getMDReapers();
|
||||
const auto& reapers = cfg->getMDReapers();
|
||||
if (reapers.empty())
|
||||
return;
|
||||
map<char,string> smap = {{'f', path}};
|
||||
for (vector<MDReaper>::const_iterator rp = reapers.begin();
|
||||
rp != reapers.end(); rp++) {
|
||||
for (const auto& reaper : reapers) {
|
||||
vector<string> cmd;
|
||||
for (vector<string>::const_iterator it = rp->cmdv.begin();
|
||||
it != rp->cmdv.end(); it++) {
|
||||
for (const auto& arg : reaper.cmdv) {
|
||||
string s;
|
||||
pcSubst(*it, s, smap);
|
||||
pcSubst(arg, s, smap);
|
||||
cmd.push_back(s);
|
||||
}
|
||||
string output;
|
||||
if (ExecCmd::backtick(cmd, output)) {
|
||||
cfields[rp->fieldname] = output;
|
||||
cfields[reaper.fieldname] = output;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,25 +121,22 @@ void reapMetaCmds(RclConfig* cfg, const string& path,
|
||||
// "modificationdate" will set mtime instead of an ordinary field,
|
||||
// and the output from anything beginning with "rclmulti" will be
|
||||
// interpreted as multiple fields in configuration file format...
|
||||
void docFieldsFromMetaCmds(RclConfig *cfg, const map<string, string>& cfields,
|
||||
Rcl::Doc& doc)
|
||||
void docFieldsFromMetaCmds(RclConfig *cfg, const map<string, string>& cfields, Rcl::Doc& doc)
|
||||
{
|
||||
for (map<string,string>::const_iterator it = cfields.begin();
|
||||
it != cfields.end(); it++) {
|
||||
if (!it->first.compare(0, 8, "rclmulti")) {
|
||||
ConfSimple simple(it->second);
|
||||
for (const auto& cfld : cfields) {
|
||||
if (!cfld.first.compare(0, 8, "rclmulti")) {
|
||||
ConfSimple simple(cfld.second);
|
||||
if (simple.ok()) {
|
||||
vector<string> names = simple.getNames("");
|
||||
for (vector<string>::const_iterator nm = names.begin();
|
||||
nm != names.end(); nm++) {
|
||||
auto names = simple.getNames("");
|
||||
for (const auto& nm : names) {
|
||||
string value;
|
||||
if (simple.get(*nm, value)) {
|
||||
docfieldfrommeta(cfg, *nm, value, doc);
|
||||
if (simple.get(nm, value)) {
|
||||
docfieldfrommeta(cfg, nm, value, doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
docfieldfrommeta(cfg, it->first, it->second, doc);
|
||||
docfieldfrommeta(cfg, cfld.first, cfld.second, doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,8 +39,7 @@ public:
|
||||
virtual void clear_impl() override;
|
||||
|
||||
protected:
|
||||
virtual bool set_document_file_impl(const std::string&,
|
||||
const std::string&) override;
|
||||
virtual bool set_document_file_impl(const std::string&, const std::string&) override;
|
||||
|
||||
class Internal;
|
||||
private:
|
||||
|
||||
@ -35,9 +35,8 @@
|
||||
class MimeHandlerNull : public RecollFilter {
|
||||
public:
|
||||
MimeHandlerNull(RclConfig *cnf, const std::string& id)
|
||||
: RecollFilter(cnf, id) {
|
||||
}
|
||||
virtual ~MimeHandlerNull() {}
|
||||
: RecollFilter(cnf, id) {}
|
||||
virtual ~MimeHandlerNull() = default;
|
||||
MimeHandlerNull(const MimeHandlerNull&) = delete;
|
||||
MimeHandlerNull& operator=(const MimeHandlerNull&) = delete;
|
||||
|
||||
@ -45,8 +44,7 @@ class MimeHandlerNull : public RecollFilter {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool next_document()
|
||||
{
|
||||
virtual bool next_document() {
|
||||
if (m_havedoc == false)
|
||||
return false;
|
||||
m_havedoc = false;
|
||||
|
||||
@ -36,9 +36,8 @@
|
||||
class MimeHandlerSymlink : public RecollFilter {
|
||||
public:
|
||||
MimeHandlerSymlink(RclConfig *cnf, const std::string& id)
|
||||
: RecollFilter(cnf, id) {
|
||||
}
|
||||
virtual ~MimeHandlerSymlink() {}
|
||||
: RecollFilter(cnf, id) {}
|
||||
virtual ~MimeHandlerSymlink() = default;
|
||||
MimeHandlerSymlink(const MimeHandlerSymlink&) = delete;
|
||||
MimeHandlerSymlink& operator=(const MimeHandlerSymlink&) = delete;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user