added support for openoffice and word + optimized decomp temp dir usage
This commit is contained in:
+20
-2
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.4 2005-02-04 14:21:17 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.5 2005-02-09 12:07:30 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -22,6 +22,8 @@ static char rcsid[] = "@(#$Id: indexer.cpp,v 1.4 2005-02-04 14:21:17 dockes Exp
|
||||
#include "transcode.h"
|
||||
#include "debuglog.h"
|
||||
#include "internfile.h"
|
||||
#include "smallut.h"
|
||||
#include "wipedir.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -38,11 +40,21 @@ class DbIndexer {
|
||||
string dbdir;
|
||||
list<string> *topdirs;
|
||||
Rcl::Db db;
|
||||
string tmpdir;
|
||||
public:
|
||||
DbIndexer(RclConfig *cnf, const string &dbd, list<string> *top)
|
||||
: config(cnf), dbdir(dbd), topdirs(top)
|
||||
{ }
|
||||
|
||||
~DbIndexer() {
|
||||
if (tmpdir.length()) {
|
||||
wipedir(tmpdir);
|
||||
if (rmdir(tmpdir.c_str()) < 0) {
|
||||
LOGERR(("DbIndexer::~DbIndexer: cant clear temp dir %s\n",
|
||||
tmpdir.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
friend FsTreeWalker::Status
|
||||
indexfile(void *, const std::string &, const struct stat *,
|
||||
FsTreeWalker::CbFlag);
|
||||
@@ -52,6 +64,12 @@ class DbIndexer {
|
||||
|
||||
bool DbIndexer::index()
|
||||
{
|
||||
string tdir;
|
||||
|
||||
if (!maketmpdir(tmpdir)) {
|
||||
LOGERR(("DbIndexer: cant create temp directory\n"));
|
||||
return false;
|
||||
}
|
||||
if (!db.open(dbdir, Rcl::Db::DbUpd)) {
|
||||
LOGERR(("DbIndexer::index: error opening database in %s\n",
|
||||
dbdir.c_str()));
|
||||
@@ -106,7 +124,7 @@ indexfile(void *cdata, const std::string &fn, const struct stat *stp,
|
||||
}
|
||||
|
||||
Rcl::Doc doc;
|
||||
if (!internfile(fn, me->config, doc))
|
||||
if (!internfile(fn, me->config, doc, me->tmpdir))
|
||||
return FsTreeWalker::FtwOk;
|
||||
|
||||
// Set up common fields:
|
||||
|
||||
+26
-6
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.3 2004-12-15 15:00:37 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.4 2005-02-09 12:07:30 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -9,15 +9,34 @@ using std::string;
|
||||
|
||||
#include "mimetype.h"
|
||||
|
||||
string mimetype(const string &filename, ConfTree *mtypes)
|
||||
string mimetype(const string &fn, ConfTree *mtypes)
|
||||
{
|
||||
if (mtypes == 0)
|
||||
return "";
|
||||
|
||||
// If filename has a suffix and we find it in the map, we're done
|
||||
string::size_type dot = filename.find_last_of(".");
|
||||
static list<string> stoplist;
|
||||
if (stoplist.empty()) {
|
||||
string stp;
|
||||
if (mtypes->get(string("recoll_noindex"), stp, "")) {
|
||||
ConfTree::stringToStrings(stp, stoplist);
|
||||
}
|
||||
}
|
||||
|
||||
if (!stoplist.empty()) {
|
||||
for (list<string>::const_iterator it = stoplist.begin();
|
||||
it != stoplist.end(); it++) {
|
||||
if (it->length() > fn.length())
|
||||
continue;
|
||||
if (!fn.compare(fn.length() - it->length(), string::npos,
|
||||
*it))
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// If the file name has a suffix and we find it in the map, we're done
|
||||
string::size_type dot = fn.find_last_of(".");
|
||||
if (dot != string::npos) {
|
||||
string suff = filename.substr(dot);
|
||||
string suff = fn.substr(dot);
|
||||
for (unsigned int i = 0; i < suff.length(); i++)
|
||||
suff[i] = tolower(suff[i]);
|
||||
|
||||
@@ -25,7 +44,8 @@ string mimetype(const string &filename, ConfTree *mtypes)
|
||||
if (mtypes->get(suff, mtype, ""))
|
||||
return mtype;
|
||||
}
|
||||
// Look at file data
|
||||
|
||||
// Look at file data ? One day maybe
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user