show current filename as feedback during indexation

This commit is contained in:
dockes
2006-03-22 16:24:41 +00:00
parent 462000eca2
commit e4d066994a
6 changed files with 83 additions and 30 deletions
+4 -2
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.25 2006-03-20 16:05:41 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.26 2006-03-22 16:24:41 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -200,6 +200,8 @@ FsTreeWalker::Status
DbIndexer::processone(const std::string &fn, const struct stat *stp,
FsTreeWalker::CbFlag flg)
{
if (m_updfunc)
m_updfunc->update(fn);
// If we're changing directories, possibly adjust parameters (set
// the current directory in configuration object)
if (flg == FsTreeWalker::FtwDirEnter ||
@@ -309,7 +311,7 @@ bool ConfIndexer::index(bool resetbefore)
// cout << *dit << " ";
//}
//cout << endl;
dbindexer = new DbIndexer(config, dbit->first);
dbindexer = new DbIndexer(config, dbit->first, m_updfunc);
if (!dbindexer->indexDb(resetbefore, &dbit->second)) {
deleteZ(dbindexer);
return false;
+20 -8
View File
@@ -16,7 +16,7 @@
*/
#ifndef _INDEXER_H_INCLUDED_
#define _INDEXER_H_INCLUDED_
/* @(#$Id: indexer.h,v 1.10 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: indexer.h,v 1.11 2006-03-22 16:24:41 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <list>
@@ -28,6 +28,13 @@
/* Forward decl for lower level indexing object */
class DbIndexer;
/* Callback to say what we're doing */
class DbIxStatusUpdater {
public:
virtual ~DbIxStatusUpdater(){}
virtual void update(const std::string &) = 0;
};
/**
The top level indexing object. Processes the configuration, then invokes
file system walking to populate/update the database(s).
@@ -40,15 +47,16 @@ class DbIndexer;
class ConfIndexer {
public:
enum runStatus {IndexerOk, IndexerError};
ConfIndexer(RclConfig *cnf) : config(cnf), dbindexer(0)
{
}
ConfIndexer(RclConfig *cnf, DbIxStatusUpdater *updfunc = 0)
: config(cnf), dbindexer(0), m_updfunc(updfunc)
{}
virtual ~ConfIndexer();
/** Worker function: doe the actual indexing */
bool index(bool resetbefore = false);
private:
RclConfig *config;
DbIndexer *dbindexer; // Object to process directories for a given db
RclConfig *config;
DbIndexer *dbindexer; // Object to process directories for a given db
DbIxStatusUpdater *m_updfunc;
};
/** Index things into one database
@@ -64,8 +72,11 @@ Single file(s) indexing: no database purging or stem db updating.
class DbIndexer : public FsTreeWalkerCB {
public:
/** Constructor does nothing but store parameters */
DbIndexer(RclConfig *cnf, const std::string &dbd)
: config(cnf), dbdir(dbd) {
DbIndexer(RclConfig *cnf, // Configuration data
const std::string &dbd, // Place where the db lives
DbIxStatusUpdater *updfunc = 0 // status updater callback
)
: config(cnf), dbdir(dbd), m_updfunc(updfunc) {
}
virtual ~DbIndexer();
@@ -99,6 +110,7 @@ class DbIndexer : public FsTreeWalkerCB {
std::string dbdir;
Rcl::Db db;
std::string tmpdir;
DbIxStatusUpdater *m_updfunc;
bool init(bool rst = false);
};