index directory names

This commit is contained in:
dockes
2006-12-19 08:40:50 +00:00
parent 6127cbf028
commit 50b01c6ea4
10 changed files with 78 additions and 36 deletions
+14 -7
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.21 2006-12-16 15:39:54 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.22 2006-12-19 08:40:50 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -111,7 +111,8 @@ void FileInterner::tmpcleanup()
// Handler==0 on return says we're in error, will be handled when calling
// internfile
FileInterner::FileInterner(const std::string &f, RclConfig *cnf,
FileInterner::FileInterner(const std::string &f, const struct stat *stp,
RclConfig *cnf,
const string& td, const string *imime)
: m_cfg(cnf), m_fn(f), m_forPreview(imime?true:false), m_tdir(td)
{
@@ -121,7 +122,7 @@ FileInterner::FileInterner(const std::string &f, RclConfig *cnf,
// We need to run mime type identification in any case to check
// for a compressed file.
string l_mime = mimetype(m_fn, m_cfg, usfci);
string l_mime = mimetype(m_fn, stp, m_cfg, usfci);
// If identification fails, try to use the input parameter. This
// is then normally not a compressed type (it's the mime type from
@@ -141,7 +142,8 @@ FileInterner::FileInterner(const std::string &f, RclConfig *cnf,
LOGDEB1(("internfile: after ucomp: m_tdir %s, tfile %s\n",
m_tdir.c_str(), m_tfile.c_str()));
m_fn = m_tfile;
l_mime = mimetype(m_fn, m_cfg, usfci);
// Note: still using the original file's stat. right ?
l_mime = mimetype(m_fn, stp, m_cfg, usfci);
if (l_mime.empty() && imime)
l_mime = *imime;
}
@@ -468,15 +470,20 @@ class DirWiper {
};
bool FileInterner::idocTempFile(TempFile& otemp, RclConfig *cnf,
const string& fn, const string& ipath,
const string& fn,
const string& ipath,
const string& mtype)
{
string tmpdir, reason;
if (!maketmpdir(tmpdir, reason))
return false;
DirWiper wiper(tmpdir);
FileInterner interner(fn, cnf, tmpdir, &mtype);
struct stat st;
if (stat(fn.c_str(), &st) < 0) {
LOGERR(("FileInterner::idocTempFile: can't stat [%s]\n", fn.c_str()));
return false;
}
FileInterner interner(fn, &st, cnf, tmpdir, &mtype);
interner.setTargetMType(mtype);
Rcl::Doc doc;
string mipath = ipath;
+5 -2
View File
@@ -16,7 +16,7 @@
*/
#ifndef _INTERNFILE_H_INCLUDED_
#define _INTERNFILE_H_INCLUDED_
/* @(#$Id: internfile.h,v 1.9 2006-12-16 15:39:54 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: internfile.h,v 1.10 2006-12-19 08:40:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <vector>
@@ -31,6 +31,8 @@ namespace Rcl {
class Doc;
}
struct stat;
/**
* A class to convert a file into possibly multiple documents in internal
* representation.
@@ -52,7 +54,8 @@ class FileInterner {
* mime type for the uncompressed version. This currently doubles up
* to indicate that this object is for previewing (not indexing).
*/
FileInterner(const string &fn, RclConfig *cnf, const string& td,
FileInterner(const string &fn, const struct stat *stp,
RclConfig *cnf, const string& td,
const string *mtype = 0);
~FileInterner();
+12 -10
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.20 2006-12-15 12:40:02 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.21 2006-12-19 08:40:50 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -38,16 +38,18 @@ using namespace std;
/** Create internal handler object appropriate for given mime type */
static Dijon::Filter *mhFactory(const string &mime)
{
if (!stringlowercmp("text/plain", mime))
return new MimeHandlerText("text/plain");
else if (!stringlowercmp("text/html", mime))
return new MimeHandlerHtml("text/html");
else if (!stringlowercmp("text/x-mail", mime))
return new MimeHandlerMbox("text/x-mail");
else if (!stringlowercmp("message/rfc822", mime))
return new MimeHandlerMail("message/rfc822");
string lmime(mime);
stringtolower(lmime);
if ("text/plain" == lmime)
return new MimeHandlerText(lmime);
else if ("text/html" == lmime)
return new MimeHandlerHtml(lmime);
else if ("text/x-mail" == lmime)
return new MimeHandlerMbox(lmime);
else if ("message/rfc822" == lmime)
return new MimeHandlerMail(lmime);
else
return new MimeHandlerUnknown("application/octet-stream");
return new MimeHandlerUnknown(lmime);
}
/**