mimemap processing recentered in rclconfig. Handle directory-local suffix to mime-type definitions. Implement gaim log handling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.15 2005-11-14 09:57:11 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.16 2005-11-21 14:31:24 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -215,11 +215,9 @@ ConfIndexer::~ConfIndexer()
|
||||
|
||||
bool ConfIndexer::index()
|
||||
{
|
||||
ConfTree *conf = config->getConfig();
|
||||
|
||||
// Retrieve the list of directories to be indexed.
|
||||
string topdirs;
|
||||
if (conf->get("topdirs", topdirs, "") == 0) {
|
||||
if (!config->getConfParam("topdirs", topdirs)) {
|
||||
LOGERR(("ConfIndexer::index: no top directories in configuration\n"));
|
||||
return false;
|
||||
}
|
||||
@@ -239,7 +237,8 @@ bool ConfIndexer::index()
|
||||
for (dirit = tdl.begin(); dirit != tdl.end(); dirit++) {
|
||||
string db;
|
||||
string dir = path_tildexpand(*dirit);
|
||||
if (conf->get("dbdir", db, dir) == 0) {
|
||||
config->setKeyDir(dir);
|
||||
if (!config->getConfParam("dbdir", db)) {
|
||||
LOGERR(("ConfIndexer::index: no database directory in "
|
||||
"configuration for %s\n", dir.c_str()));
|
||||
return false;
|
||||
@@ -254,6 +253,7 @@ bool ConfIndexer::index()
|
||||
dbit->second.push_back(dir);
|
||||
}
|
||||
}
|
||||
config->setKeyDir("");
|
||||
|
||||
// Index each directory group in turn
|
||||
for (dbit = dbmap.begin(); dbit != dbmap.end(); dbit++) {
|
||||
|
||||
+13
-25
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.10 2005-11-10 08:47:49 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.11 2005-11-21 14:31:24 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#ifndef TEST_MIMETYPE
|
||||
@@ -13,7 +13,7 @@ using std::list;
|
||||
#include "mimetype.h"
|
||||
#include "debuglog.h"
|
||||
#include "execmd.h"
|
||||
#include "conftree.h"
|
||||
#include "rclconfig.h"
|
||||
#include "smallut.h"
|
||||
#include "idfile.h"
|
||||
|
||||
@@ -82,26 +82,20 @@ static string mimetypefromdata(const string &fn, bool usfc)
|
||||
/// Guess mime type, first from suffix, then from file data. We also
|
||||
/// have a list of suffixes that we don't touch at all (ie: .jpg,
|
||||
/// etc...)
|
||||
string mimetype(const string &fn, ConfTree *mtypes, bool usfc)
|
||||
string mimetype(const string &fn, RclConfig *cfg, bool usfc)
|
||||
{
|
||||
if (mtypes == 0)
|
||||
if (cfg == 0)
|
||||
return "";
|
||||
|
||||
static list<string> stoplist;
|
||||
if (stoplist.empty()) {
|
||||
string stp;
|
||||
if (mtypes->get(string("recoll_noindex"), stp, "")) {
|
||||
ConfTree::stringToStrings(stp, stoplist);
|
||||
}
|
||||
}
|
||||
|
||||
list<string> stoplist;
|
||||
cfg->getStopSuffixes(stoplist);
|
||||
if (!stoplist.empty()) {
|
||||
for (list<string>::const_iterator it = stoplist.begin();
|
||||
it != stoplist.end(); it++) {
|
||||
if (it->length() > fn.length())
|
||||
continue;
|
||||
if (!stringicmp(fn.substr(fn.length() - it->length(),string::npos),
|
||||
*it)) {
|
||||
if (!stringicmp(fn.substr(fn.length() - it->length(),
|
||||
string::npos), *it)) {
|
||||
LOGDEB(("mimetype: fn %s in stoplist (%s)\n", fn.c_str(),
|
||||
it->c_str()));
|
||||
return "";
|
||||
@@ -109,7 +103,7 @@ string mimetype(const string &fn, ConfTree *mtypes, bool usfc)
|
||||
}
|
||||
}
|
||||
|
||||
// If the file name has a suffix and we find it in the map, we're done
|
||||
// Look for suffix in mimetype map
|
||||
string::size_type dot = fn.find_last_of(".");
|
||||
string suff;
|
||||
if (dot != string::npos) {
|
||||
@@ -117,18 +111,12 @@ string mimetype(const string &fn, ConfTree *mtypes, bool usfc)
|
||||
for (unsigned int i = 0; i < suff.length(); i++)
|
||||
suff[i] = tolower(suff[i]);
|
||||
|
||||
string mtype;
|
||||
if (mtypes->get(suff, mtype, ""))
|
||||
string mtype = cfg->getMimeTypeFromSuffix(suff);
|
||||
if (!mtype.empty())
|
||||
return mtype;
|
||||
}
|
||||
|
||||
// Look at file data ? Only when no suffix or always ?
|
||||
#if 0
|
||||
// Don't do this only for empty suffixes: would cause problems
|
||||
// with shifted files, like messages.1, messages.2 etc... And others too
|
||||
if (suff.empty())
|
||||
#endif
|
||||
return mimetypefromdata(fn, usfc);
|
||||
return mimetypefromdata(fn, usfc);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +146,7 @@ int main(int argc, const char **argv)
|
||||
while (--argc > 0) {
|
||||
string filename = *++argv;
|
||||
cout << filename << " -> " <<
|
||||
mimetype(filename, config->getMimeMap(), true) << endl;
|
||||
mimetype(filename, config, true) << endl;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#ifndef _MIMETYPE_H_INCLUDED_
|
||||
#define _MIMETYPE_H_INCLUDED_
|
||||
/* @(#$Id: mimetype.h,v 1.3 2005-11-10 08:47:49 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: mimetype.h,v 1.4 2005-11-21 14:31:24 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include "conftree.h"
|
||||
|
||||
class RclConfig;
|
||||
|
||||
/**
|
||||
* Try to determine a mime type for filename.
|
||||
* This may imply more than matching the suffix, the name must be usable
|
||||
* to actually access file data.
|
||||
*/
|
||||
string mimetype(const std::string &filename, ConfTree *mtypes, bool usfc);
|
||||
string mimetype(const std::string &filename, RclConfig *cfg, bool usfc);
|
||||
|
||||
|
||||
#endif /* _MIMETYPE_H_INCLUDED_ */
|
||||
|
||||
Reference in New Issue
Block a user