本文整理汇总了C++中IndexReader::getChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ IndexReader::getChildren方法的具体用法?C++ IndexReader::getChildren怎么用?C++ IndexReader::getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexReader
的用法示例。
在下文中一共展示了IndexReader::getChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analysisresult
void
DirAnalyzer::Private::update(StreamAnalyzer* analyzer) {
IndexReader* reader = manager.indexReader();
vector<pair<string, struct stat> > dirfiles;
map<string, time_t> dbdirfiles;
vector<string> toDelete;
vector<pair<string, struct stat> > toIndex;
try {
string path;
// loop over all files that exist in the index
int r = dirlister.nextDir(path, dirfiles);
while (r >= 0 && (caller == 0 || caller->continueAnalysis())) {
if (r < 0) {
continue;
}
// get the files that are in the current database
reader->getChildren(path, dbdirfiles);
// get all files in this directory
vector<pair<string, struct stat> >::const_iterator end
= dirfiles.end();
map<string, time_t>::const_iterator dbend = dbdirfiles.end();
for (vector<pair<string, struct stat> >::const_iterator i
= dirfiles.begin(); i != end; ++i) {
const string& filepath(i->first);
time_t mtime = i->second.st_mtime;
// check if this file is new or not
map<string, time_t>::iterator j = dbdirfiles.find(filepath);
bool newfile = j == dbend;
bool updatedfile = !newfile && j->second != mtime;
if (newfile || (updatedfile && !S_ISDIR(i->second.st_mode))) {
// if the file has not yet been indexed or if the mtime has
// changed, index it
// if a directory has been updated, this will not change the index
// so the entry is not removed from the index, nor reindexed
toIndex.push_back(make_pair(filepath, i->second));
} else {
// files left in dbdirfiles after this loop will be deleted from the
// index. because this file has not changed, it should not be
// removed from the index
dbdirfiles.erase(j);
}
}
// all the files left in dbdirfiles, are not in the current
// directory and should be deleted
for (map<string, time_t>::const_iterator i = dbdirfiles.begin();
i != dbend; ++i) {
toDelete.push_back(i->first);
}
if (toDelete.size() > 0) {
manager.indexWriter()->deleteEntries(toDelete);
}
vector<pair<string, struct stat> >::const_iterator fend
= toIndex.end();
for (vector<pair<string, struct stat> >::const_iterator i
= toIndex.begin(); i != fend; ++i) {
AnalysisResult analysisresult(i->first, i->second.st_mtime,
*manager.indexWriter(), *analyzer, path);
if (S_ISREG(i->second.st_mode)) {
InputStream* file = FileInputStream::open(i->first.c_str());
analysisresult.index(file);
delete file;
} else {
analysisresult.index(0);
}
}
toDelete.clear();
toIndex.clear();
r = dirlister.nextDir(path, dirfiles);
}
} catch(...) {
fprintf(stderr, "Unknown error\n");
}
}