cosmetics: list -> vector in more places
This commit is contained in:
@@ -217,7 +217,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Return list of candidate offsets for udi (possibly several
|
||||
// Return vector of candidate offsets for udi (possibly several
|
||||
// because there may be hash collisions, and also multiple
|
||||
// instances).
|
||||
bool khFind(const string& udi, vector<off_t>& ofss)
|
||||
@@ -262,10 +262,10 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Clear entries for list of udi/offs
|
||||
bool khClear(const list<pair<string, off_t> >& udis)
|
||||
// Clear entries for vector of udi/offs
|
||||
bool khClear(const vector<pair<string, off_t> >& udis)
|
||||
{
|
||||
for (list<pair<string, off_t> >::const_iterator it = udis.begin();
|
||||
for (vector<pair<string, off_t> >::const_iterator it = udis.begin();
|
||||
it != udis.end(); it++)
|
||||
khClear(*it);
|
||||
return true;
|
||||
@@ -754,7 +754,7 @@ bool CirCache::get(const string& udi, string& dic, string& data, int instance)
|
||||
if (!fudi.compare(udi)) {
|
||||
// Found one, memorize offset. Done if instance
|
||||
// matches, else go on. If instance is -1 need to
|
||||
// go to the end of the list anyway
|
||||
// go to the end anyway
|
||||
d_good = d;
|
||||
o_good = *it;
|
||||
if (finst == instance) {
|
||||
@@ -849,7 +849,7 @@ class CCScanHookSpacer : public CCScanHook {
|
||||
public:
|
||||
UINT sizewanted;
|
||||
UINT sizeseen;
|
||||
list<pair<string, off_t> > squashed_udis;
|
||||
vector<pair<string, off_t> > squashed_udis;
|
||||
CCScanHookSpacer(int sz)
|
||||
: sizewanted(sz), sizeseen(0) {assert(sz > 0);}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* an exec (security, pipe control, the possibility that a bug will trigger
|
||||
* an unwanted write, etc.)
|
||||
*
|
||||
* A process has currently no POSIX way to determine the list of open file
|
||||
* A process has currently no POSIX way to determine the set of open file
|
||||
* descriptors or at least the highest value. Closing all files (except a few),
|
||||
* thus implies performing a close() system call on each entry up to the
|
||||
* maximum, which can be both relatively difficult to determine, and quite
|
||||
@@ -46,7 +46,7 @@
|
||||
* System interfaces:
|
||||
* FreeBSD:
|
||||
* - Has a closefrom() system call as of release 7.x around Sep 2009
|
||||
* - Has a /dev/fd, directory which lists the current process' open
|
||||
* - Has a /dev/fd, directory which shows the current process' open
|
||||
* descriptors. Only descriptors 0, 1, 2 are shown except if
|
||||
* fdescfs is mounted which it is not by default
|
||||
*
|
||||
|
||||
+28
-29
@@ -37,7 +37,6 @@
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using namespace std;
|
||||
using std::list;
|
||||
#endif // NO_NAMESPACES
|
||||
|
||||
#ifndef MIN
|
||||
@@ -346,7 +345,7 @@ int ConfSimple::i_set(const std::string &nm, const std::string &value,
|
||||
// at begin() for a null subkey, or just behind the subkey
|
||||
// entry. End is either the next subkey entry, or the end of
|
||||
// list. We insert the new entry just before end.
|
||||
list<ConfLine>::iterator start, fin;
|
||||
vector<ConfLine>::iterator start, fin;
|
||||
if (sk.empty()) {
|
||||
start = m_order.begin();
|
||||
LOGDEB((stderr,"ConfSimple::i_set: null sk, start at top of order\n"));
|
||||
@@ -367,7 +366,7 @@ int ConfSimple::i_set(const std::string &nm, const std::string &value,
|
||||
// The null subkey has no entry (maybe it should)
|
||||
if (!sk.empty())
|
||||
start++;
|
||||
for (list<ConfLine>::iterator it = start; it != m_order.end(); it++) {
|
||||
for (vector<ConfLine>::iterator it = start; it != m_order.end(); it++) {
|
||||
if (it->m_kind == ConfLine::CFL_SK) {
|
||||
fin = it;
|
||||
break;
|
||||
@@ -402,8 +401,8 @@ int ConfSimple::erase(const string &nm, const string &sk)
|
||||
|
||||
int ConfSimple::eraseKey(const string &sk)
|
||||
{
|
||||
list<string>nms = getNames(sk);
|
||||
for (list<string>::iterator it = nms.begin(); it != nms.end(); it++) {
|
||||
vector<string> nms = getNames(sk);
|
||||
for (vector<string>::iterator it = nms.begin(); it != nms.end(); it++) {
|
||||
erase(*it, sk);
|
||||
}
|
||||
return write();
|
||||
@@ -460,13 +459,13 @@ bool ConfSimple::write()
|
||||
|
||||
// Write out the tree in configuration file format:
|
||||
// This does not check holdWrites, this is done by write(void), which
|
||||
// lets ie: listall work even when holdWrites is set
|
||||
// lets ie: showall work even when holdWrites is set
|
||||
bool ConfSimple::write(ostream& out) const
|
||||
{
|
||||
if (!ok())
|
||||
return false;
|
||||
string sk;
|
||||
for (list<ConfLine>::const_iterator it = m_order.begin();
|
||||
for (vector<ConfLine>::const_iterator it = m_order.begin();
|
||||
it != m_order.end(); it++) {
|
||||
switch(it->m_kind) {
|
||||
case ConfLine::CFL_COMMENT:
|
||||
@@ -509,38 +508,38 @@ bool ConfSimple::write(ostream& out) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfSimple::listall()
|
||||
void ConfSimple::showall()
|
||||
{
|
||||
if (!ok())
|
||||
return;
|
||||
write(std::cout);
|
||||
}
|
||||
|
||||
list<string> ConfSimple::getNames(const string &sk, const char *pattern)
|
||||
vector<string> ConfSimple::getNames(const string &sk, const char *pattern)
|
||||
{
|
||||
std::list<string> mylist;
|
||||
vector<string> mylist;
|
||||
if (!ok())
|
||||
return mylist;
|
||||
map<string, map<string, string> >::iterator ss;
|
||||
if ((ss = m_submaps.find(sk)) == m_submaps.end()) {
|
||||
return mylist;
|
||||
}
|
||||
mylist.reserve(ss->second.size());
|
||||
map<string, string>::const_iterator it;
|
||||
for (it = ss->second.begin();it != ss->second.end();it++) {
|
||||
for (it = ss->second.begin(); it != ss->second.end(); it++) {
|
||||
if (pattern && FNM_NOMATCH == fnmatch(pattern, it->first.c_str(), 0))
|
||||
continue;
|
||||
mylist.push_back(it->first);
|
||||
}
|
||||
mylist.sort();
|
||||
mylist.unique();
|
||||
return mylist;
|
||||
}
|
||||
|
||||
list<string> ConfSimple::getSubKeys()
|
||||
vector<string> ConfSimple::getSubKeys()
|
||||
{
|
||||
std::list<string> mylist;
|
||||
vector<string> mylist;
|
||||
if (!ok())
|
||||
return mylist;
|
||||
mylist.reserve(m_submaps.size());
|
||||
map<string, map<string, string> >::iterator ss;
|
||||
for (ss = m_submaps.begin(); ss != m_submaps.end(); ss++) {
|
||||
mylist.push_back(ss->first);
|
||||
@@ -550,8 +549,8 @@ list<string> ConfSimple::getSubKeys()
|
||||
|
||||
bool ConfSimple::hasNameAnywhere(const string& nm)
|
||||
{
|
||||
list<string>keys = getSubKeys();
|
||||
for (list<string>::const_iterator it = keys.begin();
|
||||
vector<string>keys = getSubKeys();
|
||||
for (vector<string>::const_iterator it = keys.begin();
|
||||
it != keys.end(); it++) {
|
||||
string val;
|
||||
if (get(nm, val, *it))
|
||||
@@ -603,7 +602,7 @@ int ConfTree::get(const std::string &name, string &value, const string &sk)
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "conftree.h"
|
||||
#include "smallut.h"
|
||||
@@ -700,7 +699,7 @@ const char *longvalue =
|
||||
void memtest(ConfSimple &c)
|
||||
{
|
||||
cout << "Initial:" << endl;
|
||||
c.listall();
|
||||
c.showall();
|
||||
if (c.set("nom", "avec nl \n 2eme ligne", "")) {
|
||||
fprintf(stderr, "set with embedded nl succeeded !\n");
|
||||
exit(1);
|
||||
@@ -719,7 +718,7 @@ void memtest(ConfSimple &c)
|
||||
}
|
||||
|
||||
cout << "Final:" << endl;
|
||||
c.listall();
|
||||
c.showall();
|
||||
}
|
||||
|
||||
bool readwrite(ConfNull *conf)
|
||||
@@ -924,7 +923,7 @@ int main(int argc, char **argv)
|
||||
if (op_flags & OPT_U) {
|
||||
exit(!complex_updates(argv[0]));
|
||||
}
|
||||
list<string> flist;
|
||||
vector<string> flist;
|
||||
while (argc--) {
|
||||
flist.push_back(*argv++);
|
||||
}
|
||||
@@ -951,8 +950,8 @@ int main(int argc, char **argv)
|
||||
cerr << "conf init error" << endl;
|
||||
exit(1);
|
||||
}
|
||||
list<string>lst = conf->getSubKeys();
|
||||
for (list<string>::const_iterator it = lst.begin();
|
||||
vector<string>lst = conf->getSubKeys();
|
||||
for (vector<string>::const_iterator it = lst.begin();
|
||||
it != lst.end(); it++) {
|
||||
cout << *it << endl;
|
||||
}
|
||||
@@ -975,13 +974,13 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
cout << "source: [" << source << "]" << endl;
|
||||
list<string> strings;
|
||||
vector<string> strings;
|
||||
if (!stringToStrings(source, strings)) {
|
||||
cerr << "parse failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (list<string>::iterator it = strings.begin();
|
||||
for (vector<string>::iterator it = strings.begin();
|
||||
it != strings.end(); it++) {
|
||||
cout << "[" << *it << "]" << endl;
|
||||
}
|
||||
@@ -992,17 +991,17 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
printf("LIST\n");
|
||||
conf->listall();
|
||||
conf->showall();
|
||||
//printf("WALK\n");conf->sortwalk(mywalker, 0);
|
||||
printf("\nNAMES in global space:\n");
|
||||
list<string> names = conf->getNames("");
|
||||
for (list<string>::iterator it = names.begin();
|
||||
vector<string> names = conf->getNames("");
|
||||
for (vector<string>::iterator it = names.begin();
|
||||
it!=names.end(); it++)
|
||||
cout << *it << " ";
|
||||
cout << endl;
|
||||
printf("\nNAMES in global space matching t* \n");
|
||||
names = conf->getNames("", "t*");
|
||||
for (list<string>::iterator it = names.begin();
|
||||
for (vector<string>::iterator it = names.begin();
|
||||
it!=names.end(); it++)
|
||||
cout << *it << " ";
|
||||
cout << endl;
|
||||
|
||||
+44
-44
@@ -51,7 +51,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
// rh7.3 likes iostream better...
|
||||
#if defined(__GNUC__) && __GNUC__ < 3
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
@@ -100,12 +100,12 @@ public:
|
||||
virtual int set(const string &nm, const string &val,
|
||||
const string &sk = string()) = 0;
|
||||
virtual bool ok() const = 0;
|
||||
virtual list<string> getNames(const string &sk, const char* = 0) = 0;
|
||||
virtual vector<string> getNames(const string &sk, const char* = 0) = 0;
|
||||
virtual int erase(const string &, const string &) = 0;
|
||||
virtual int eraseKey(const string &) = 0;
|
||||
virtual void listall() {};
|
||||
virtual list<string> getSubKeys() = 0;
|
||||
virtual list<string> getSubKeys(bool) = 0;
|
||||
virtual void showall() {};
|
||||
virtual vector<string> getSubKeys() = 0;
|
||||
virtual vector<string> getSubKeys(bool) = 0;
|
||||
virtual bool holdWrites(bool) = 0;
|
||||
virtual bool sourceChanged() = 0;
|
||||
};
|
||||
@@ -198,11 +198,11 @@ public:
|
||||
const string &val),
|
||||
void *clidata);
|
||||
|
||||
/** List all values to stdout */
|
||||
virtual void listall();
|
||||
/** Print all values to stdout */
|
||||
virtual void showall();
|
||||
|
||||
/** Return all names in given submap. */
|
||||
virtual list<string> getNames(const string &sk, const char *pattern = 0);
|
||||
virtual vector<string> getNames(const string &sk, const char *pattern = 0);
|
||||
|
||||
/** Check if name is present in any submap. This is relatively expensive
|
||||
* but useful for saving further processing sometimes */
|
||||
@@ -211,8 +211,8 @@ public:
|
||||
/**
|
||||
* Return all subkeys
|
||||
*/
|
||||
virtual list<string> getSubKeys(bool) {return getSubKeys();}
|
||||
virtual list<string> getSubKeys();
|
||||
virtual vector<string> getSubKeys(bool) {return getSubKeys();}
|
||||
virtual vector<string> getSubKeys();
|
||||
/** Test for subkey existence */
|
||||
virtual bool hasSubKey(const string& sk)
|
||||
{
|
||||
@@ -263,7 +263,7 @@ private:
|
||||
// Presentation data. We keep the comments, empty lines and
|
||||
// variable and subkey ordering information in there (for
|
||||
// rewriting the file while keeping hand-edited information)
|
||||
list<ConfLine> m_order;
|
||||
vector<ConfLine> m_order;
|
||||
// Control if we're writing to the backing store
|
||||
bool m_holdWrites;
|
||||
|
||||
@@ -323,7 +323,7 @@ public:
|
||||
* have a central config, with possible overrides from more specific
|
||||
* (ie personal) ones.
|
||||
*
|
||||
* Notes: it's ok for some of the files in the list to not exist, but the last
|
||||
* Notes: it's ok for some of the files not to exist, but the last
|
||||
* one must or we generate an error. We open all trees readonly, except the
|
||||
* topmost one if requested. All writes go to the topmost file. Note that
|
||||
* erase() won't work except for parameters only defined in the topmost
|
||||
@@ -331,18 +331,18 @@ public:
|
||||
*/
|
||||
template <class T> class ConfStack : public ConfNull {
|
||||
public:
|
||||
/// Construct from list of configuration file names. The earler
|
||||
/// Construct from configuration file names. The earler
|
||||
/// files in have priority when fetching values. Only the first
|
||||
/// file will be updated if ro is false and set() is used.
|
||||
ConfStack(const list<string> &fns, bool ro = true)
|
||||
ConfStack(const vector<string> &fns, bool ro = true)
|
||||
{
|
||||
construct(fns, ro);
|
||||
}
|
||||
/// Construct out of single file name and list of directories
|
||||
ConfStack(const string& nm, const list<string>& dirs, bool ro = true)
|
||||
/// Construct out of single file name and multiple directories
|
||||
ConfStack(const string& nm, const vector<string>& dirs, bool ro = true)
|
||||
{
|
||||
list<string> fns;
|
||||
for (list<string>::const_iterator it = dirs.begin();
|
||||
vector<string> fns;
|
||||
for (vector<string>::const_iterator it = dirs.begin();
|
||||
it != dirs.end(); it++){
|
||||
fns.push_back(path_cat(*it, nm));
|
||||
}
|
||||
@@ -374,7 +374,7 @@ public:
|
||||
|
||||
virtual bool sourceChanged()
|
||||
{
|
||||
typename list<T*>::const_iterator it;
|
||||
typename vector<T*>::const_iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||
if ((*it)->sourceChanged())
|
||||
return true;
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
|
||||
virtual int get(const string &name, string &value, const string &sk) const
|
||||
{
|
||||
typename list<T*>::const_iterator it;
|
||||
typename vector<T*>::const_iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||
if ((*it)->get(name, value, sk))
|
||||
return true;
|
||||
@@ -394,7 +394,7 @@ public:
|
||||
|
||||
virtual bool hasNameAnywhere(const string& nm)
|
||||
{
|
||||
typename list<T*>::iterator it;
|
||||
typename vector<T*>::iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||
if ((*it)->hasNameAnywhere(nm))
|
||||
return true;
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
// Avoid adding unneeded entries: if the new value matches the
|
||||
// one out from the deeper configs, erase or dont add it
|
||||
// from/to the topmost file
|
||||
typename list<T*>::iterator it = m_confs.begin();
|
||||
typename vector<T*>::iterator it = m_confs.begin();
|
||||
it++;
|
||||
while (it != m_confs.end()) {
|
||||
string value;
|
||||
@@ -445,49 +445,49 @@ public:
|
||||
return m_confs.front()->holdWrites(on);
|
||||
}
|
||||
|
||||
virtual list<string> getNames(const string &sk, const char *pattern = 0)
|
||||
virtual vector<string> getNames(const string &sk, const char *pattern = 0)
|
||||
{
|
||||
return getNames1(sk, pattern, false);
|
||||
}
|
||||
virtual list<string> getNamesShallow(const string &sk, const char *patt = 0)
|
||||
virtual vector<string> getNamesShallow(const string &sk, const char *patt = 0)
|
||||
{
|
||||
return getNames1(sk, patt, true);
|
||||
}
|
||||
|
||||
virtual list<string> getNames1(const string &sk, const char *pattern,
|
||||
virtual vector<string> getNames1(const string &sk, const char *pattern,
|
||||
bool shallow)
|
||||
{
|
||||
list<string> nms;
|
||||
typename list<T*>::iterator it;
|
||||
vector<string> nms;
|
||||
typename vector<T*>::iterator it;
|
||||
bool skfound = false;
|
||||
for (it = m_confs.begin();it != m_confs.end(); it++) {
|
||||
if ((*it)->hasSubKey(sk)) {
|
||||
skfound = true;
|
||||
list<string> lst = (*it)->getNames(sk, pattern);
|
||||
vector<string> lst = (*it)->getNames(sk, pattern);
|
||||
nms.insert(nms.end(), lst.begin(), lst.end());
|
||||
}
|
||||
if (shallow && skfound)
|
||||
break;
|
||||
}
|
||||
nms.sort();
|
||||
nms.unique();
|
||||
sort(nms.begin(), nms.end());
|
||||
unique(nms.begin(), nms.end());
|
||||
return nms;
|
||||
}
|
||||
|
||||
virtual list<string> getSubKeys(){return getSubKeys(false);}
|
||||
virtual list<string> getSubKeys(bool shallow)
|
||||
virtual vector<string> getSubKeys(){return getSubKeys(false);}
|
||||
virtual vector<string> getSubKeys(bool shallow)
|
||||
{
|
||||
list<string> sks;
|
||||
typename list<T*>::iterator it;
|
||||
vector<string> sks;
|
||||
typename vector<T*>::iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end(); it++) {
|
||||
list<string> lst;
|
||||
vector<string> lst;
|
||||
lst = (*it)->getSubKeys();
|
||||
sks.insert(sks.end(), lst.begin(), lst.end());
|
||||
if (shallow)
|
||||
break;
|
||||
}
|
||||
sks.sort();
|
||||
sks.unique();
|
||||
sort(sks.begin(), sks.end());
|
||||
unique(sks.begin(), sks.end());
|
||||
return sks;
|
||||
}
|
||||
|
||||
@@ -495,11 +495,11 @@ public:
|
||||
|
||||
private:
|
||||
bool m_ok;
|
||||
list<T*> m_confs;
|
||||
vector<T*> m_confs;
|
||||
|
||||
/// Reset to pristine
|
||||
void clear() {
|
||||
typename list<T*>::iterator it;
|
||||
typename vector<T*>::iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||
delete (*it);
|
||||
}
|
||||
@@ -509,16 +509,16 @@ private:
|
||||
/// Common code to initialize from existing object
|
||||
void init_from(const ConfStack &rhs) {
|
||||
if ((m_ok = rhs.m_ok)) {
|
||||
typename list<T*>::const_iterator it;
|
||||
typename vector<T*>::const_iterator it;
|
||||
for (it = rhs.m_confs.begin();it != rhs.m_confs.end();it++) {
|
||||
m_confs.push_back(new T(**it));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Common construct from file list code
|
||||
void construct(const list<string> &fns, bool ro) {
|
||||
list<string>::const_iterator it;
|
||||
/// Common construct from file names code
|
||||
void construct(const vector<string> &fns, bool ro) {
|
||||
vector<string>::const_iterator it;
|
||||
bool lastok = false;
|
||||
for (it = fns.begin(); it != fns.end(); it++) {
|
||||
T* p = new T(it->c_str(), ro);
|
||||
|
||||
@@ -28,10 +28,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <list>
|
||||
using std::set;
|
||||
using std::string;
|
||||
using std::list;
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "pathut.h"
|
||||
|
||||
+17
-17
@@ -28,7 +28,8 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
#include "cstr.h"
|
||||
@@ -60,11 +61,11 @@ class FsTreeWalker::Internal {
|
||||
int options;
|
||||
int depthswitch;
|
||||
stringstream reason;
|
||||
list<string> skippedNames;
|
||||
list<string> skippedPaths;
|
||||
vector<string> skippedNames;
|
||||
vector<string> skippedPaths;
|
||||
// When doing Breadth or FilesThenDirs traversal, we keep a list
|
||||
// of directory paths to be processed, and we do not recurse.
|
||||
list<string> dirs;
|
||||
deque<string> dirs;
|
||||
int errors;
|
||||
set<DirId> donedirs;
|
||||
void logsyserr(const char *call, const string ¶m)
|
||||
@@ -119,15 +120,14 @@ bool FsTreeWalker::addSkippedName(const string& pattern)
|
||||
data->skippedNames.push_back(pattern);
|
||||
return true;
|
||||
}
|
||||
bool FsTreeWalker::setSkippedNames(const list<string> &patterns)
|
||||
bool FsTreeWalker::setSkippedNames(const vector<string> &patterns)
|
||||
{
|
||||
data->skippedNames = patterns;
|
||||
return true;
|
||||
}
|
||||
bool FsTreeWalker::inSkippedNames(const string& name)
|
||||
{
|
||||
list<string>::const_iterator it;
|
||||
for (it = data->skippedNames.begin();
|
||||
for (vector<string>::const_iterator it = data->skippedNames.begin();
|
||||
it != data->skippedNames.end(); it++) {
|
||||
if (fnmatch(it->c_str(), name.c_str(), 0) == 0) {
|
||||
return true;
|
||||
@@ -144,10 +144,10 @@ bool FsTreeWalker::addSkippedPath(const string& ipath)
|
||||
data->skippedPaths.push_back(path);
|
||||
return true;
|
||||
}
|
||||
bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
|
||||
bool FsTreeWalker::setSkippedPaths(const vector<string> &paths)
|
||||
{
|
||||
data->skippedPaths = paths;
|
||||
for (list<string>::iterator it = data->skippedPaths.begin();
|
||||
for (vector<string>::iterator it = data->skippedPaths.begin();
|
||||
it != data->skippedPaths.end(); it++)
|
||||
if (!(data->options & FtwNoCanon))
|
||||
*it = path_canon(*it);
|
||||
@@ -160,8 +160,8 @@ bool FsTreeWalker::inSkippedPaths(const string& path, bool ckparents)
|
||||
if (ckparents)
|
||||
fnmflags |= FNM_LEADING_DIR;
|
||||
#endif
|
||||
list<string>::const_iterator it;
|
||||
for (it = data->skippedPaths.begin();
|
||||
|
||||
for (vector<string>::const_iterator it = data->skippedPaths.begin();
|
||||
it != data->skippedPaths.end(); it++) {
|
||||
#ifndef FNM_LEADING_DIR
|
||||
if (ckparents) {
|
||||
@@ -217,8 +217,8 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
|
||||
}
|
||||
|
||||
// Breadth first of filesThenDirs semi-depth first order
|
||||
// Managing lists of directories to be visited later, in breadth or
|
||||
// depth order. Null marker are inserted in the list to indicate
|
||||
// Managing queues of directories to be visited later, in breadth or
|
||||
// depth order. Null marker are inserted in the queue to indicate
|
||||
// father directory changes (avoids computing parents all the time).
|
||||
data->dirs.push_back(top);
|
||||
Status status;
|
||||
@@ -226,7 +226,7 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
|
||||
string dir, nfather;
|
||||
if (data->options & (FtwTravBreadth|FtwTravBreadthThenDepth)) {
|
||||
// Breadth first, pop and process an older dir at the
|
||||
// front of the list. This will add any child dirs at the
|
||||
// front of the queue. This will add any child dirs at the
|
||||
// back
|
||||
dir = data->dirs.front();
|
||||
data->dirs.pop_front();
|
||||
@@ -279,7 +279,7 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
|
||||
return errno == ENOENT ? FtwOk : FtwError;
|
||||
}
|
||||
// iwalk will not recurse in this case, just process file entries
|
||||
// and append subdir entries to the list.
|
||||
// and append subdir entries to the queue.
|
||||
status = iwalk(dir, &st, cb);
|
||||
if (status != FtwOk)
|
||||
return status;
|
||||
@@ -497,8 +497,8 @@ Usage(void)
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
list<string> patterns;
|
||||
list<string> paths;
|
||||
vector<string> patterns;
|
||||
vector<string> paths;
|
||||
thisprog = argv[0];
|
||||
argc--; argv++;
|
||||
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
#define _FSTREEWALK_H_INCLUDED_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include <vector>
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::vector;
|
||||
#endif
|
||||
|
||||
class FsTreeWalkerCB;
|
||||
@@ -92,18 +91,17 @@ class FsTreeWalker {
|
||||
int getErrCnt();
|
||||
|
||||
/**
|
||||
* Add a pattern to the list of things (file or dir) to be ignored
|
||||
* (ie: #* , *~)
|
||||
* Add a pattern (file or dir) to be ignored (ie: #* , *~)
|
||||
*/
|
||||
bool addSkippedName(const string &pattern);
|
||||
/** Set the ignored patterns list */
|
||||
bool setSkippedNames(const list<string> &patlist);
|
||||
/** Set the ignored patterns set */
|
||||
bool setSkippedNames(const vector<string> &patterns);
|
||||
|
||||
/** Same for skipped paths: this are paths, not names, under which we
|
||||
do not descend (ie: /home/me/.recoll) */
|
||||
bool addSkippedPath(const string &path);
|
||||
/** Set the ignored paths list */
|
||||
bool setSkippedPaths(const list<string> &pathlist);
|
||||
bool setSkippedPaths(const vector<string> &patterns);
|
||||
|
||||
/** Test if path/name should be skipped. This can be used independantly of
|
||||
* an actual tree walk */
|
||||
|
||||
@@ -37,14 +37,6 @@ using namespace std;
|
||||
* to separate messages, that we don't recognize currently
|
||||
*/
|
||||
|
||||
std::list<string> idFileAllTypes()
|
||||
{
|
||||
std::list<string> lst;
|
||||
lst.push_back("text/x-mail");
|
||||
lst.push_back("message/rfc822");
|
||||
return lst;
|
||||
}
|
||||
|
||||
// Mail headers we compare to:
|
||||
static const char *mailhs[] = {"From: ", "Received: ", "Message-Id: ", "To: ",
|
||||
"Date: ", "Subject: ", "Status: ",
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#define _IDFILE_H_INCLUDED_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
// Look at data inside file or string, and return mime type or empty string.
|
||||
//
|
||||
@@ -28,7 +27,4 @@
|
||||
extern std::string idFile(const char *fn);
|
||||
extern std::string idFileMem(const std::string& data);
|
||||
|
||||
// Return all types known to us
|
||||
extern std::list<std::string> idFileAllTypes();
|
||||
|
||||
#endif /* _IDFILE_H_INCLUDED_ */
|
||||
|
||||
@@ -47,11 +47,9 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <stack>
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::stack;
|
||||
#endif /* NO_NAMESPACES */
|
||||
|
||||
@@ -363,10 +361,10 @@ extern string path_canon(const string &is)
|
||||
|
||||
#include <glob.h>
|
||||
#include <sys/stat.h>
|
||||
list<string> path_dirglob(const string &dir,
|
||||
const string pattern)
|
||||
vector<string> path_dirglob(const string &dir,
|
||||
const string pattern)
|
||||
{
|
||||
list<string> res;
|
||||
vector<string> res;
|
||||
glob_t mglob;
|
||||
string mypat=path_cat(dir, pattern);
|
||||
if (glob(mypat.c_str(), 0, 0, &mglob)) {
|
||||
@@ -673,7 +671,7 @@ int main(int argc, const char **argv)
|
||||
thisprog = *argv++;argc--;
|
||||
|
||||
string s;
|
||||
list<string>::const_iterator it;
|
||||
vector<string>::const_iterator it;
|
||||
#if 0
|
||||
for (unsigned int i = 0;i < sizeof(tstvec) / sizeof(char *); i++) {
|
||||
cout << tstvec[i] << " Father " << path_getfather(tstvec[i]) << endl;
|
||||
@@ -713,7 +711,7 @@ int main(int argc, const char **argv)
|
||||
}
|
||||
string dir = *argv++;argc--;
|
||||
string pattern = *argv++;argc--;
|
||||
list<string> matched = path_dirglob(dir, pattern);
|
||||
vector<string> matched = path_dirglob(dir, pattern);
|
||||
for (it = matched.begin(); it != matched.end();it++) {
|
||||
cout << *it << endl;
|
||||
}
|
||||
|
||||
+5
-5
@@ -19,12 +19,12 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include "refcntr.h"
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::vector;
|
||||
#endif
|
||||
|
||||
/// Add a / at the end if none there yet.
|
||||
@@ -46,9 +46,9 @@ extern string path_tildexpand(const string &s);
|
||||
extern string path_absolute(const string &s);
|
||||
/// Clean up path by removing duplicated / and resolving ../ + make it absolute
|
||||
extern string path_canon(const string &s);
|
||||
/// Use glob(3) to return a list of file names matching pattern inside dir
|
||||
extern list<string> path_dirglob(const string &dir,
|
||||
const string pattern);
|
||||
/// Use glob(3) to return the file names matching pattern inside dir
|
||||
extern vector<string> path_dirglob(const string &dir,
|
||||
const string pattern);
|
||||
/// Encode according to rfc 1738
|
||||
extern string url_encode(const string& url,
|
||||
string::size_type offs = 0);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#include "smallut.h"
|
||||
#include "utf8iter.h"
|
||||
|
||||
@@ -20,14 +20,12 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using std::set;
|
||||
|
||||
Reference in New Issue
Block a user