|
a/src/internfile/internfile.cpp |
|
b/src/internfile/internfile.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.15 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.16 2006-03-20 16:05:41 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
123 |
|
123 |
|
124 |
// We need to run mime type identification in any case to check
|
124 |
// We need to run mime type identification in any case to check
|
125 |
// for a compressed file.
|
125 |
// for a compressed file.
|
126 |
m_mime = mimetype(m_fn, m_cfg, usfci);
|
126 |
m_mime = mimetype(m_fn, m_cfg, usfci);
|
127 |
|
127 |
|
128 |
// If identification fails, try to use the input parameter. Note that this
|
128 |
// If identification fails, try to use the input parameter. This
|
129 |
// is normally not a compressed type (it's the mime type from the db)
|
129 |
// is then normally not a compressed type (it's the mime type from
|
|
|
130 |
// the db), and is only set when previewing, not for indexing
|
130 |
if (m_mime.empty() && imime)
|
131 |
if (m_mime.empty() && imime)
|
131 |
m_mime = *imime;
|
132 |
m_mime = *imime;
|
|
|
133 |
|
|
|
134 |
if (!m_mime.empty()) {
|
|
|
135 |
// Has mime: check for a compressed file. If so, create a
|
|
|
136 |
// temporary uncompressed file, and rerun the mime type
|
|
|
137 |
// identification, then do the rest with the temp file.
|
|
|
138 |
list<string>ucmd;
|
|
|
139 |
if (m_cfg->getUncompressor(m_mime, ucmd)) {
|
|
|
140 |
if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) {
|
|
|
141 |
return;
|
|
|
142 |
}
|
|
|
143 |
LOGDEB(("internfile: after ucomp: m_tdir %s, tfile %s\n",
|
|
|
144 |
m_tdir.c_str(), m_tfile.c_str()));
|
|
|
145 |
m_fn = m_tfile;
|
|
|
146 |
m_mime = mimetype(m_fn, m_cfg, usfci);
|
|
|
147 |
if (m_mime.empty() && imime)
|
|
|
148 |
m_mime = *imime;
|
|
|
149 |
}
|
|
|
150 |
}
|
|
|
151 |
|
132 |
if (m_mime.empty()) {
|
152 |
if (m_mime.empty()) {
|
133 |
// No mime type: not listed in our map, or present in stop list
|
153 |
// No mime type. We let it through as config may warrant that
|
134 |
LOGDEB(("FileInterner::FileInterner: (no mime) [%s]\n", m_fn.c_str()));
|
154 |
// we index all file names
|
135 |
return;
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
// First check for a compressed file. If so, create a temporary
|
|
|
139 |
// uncompressed file, and rerun the mime type identification, then do the
|
|
|
140 |
// rest with the temp file.
|
|
|
141 |
list<string>ucmd;
|
|
|
142 |
if (m_cfg->getUncompressor(m_mime, ucmd)) {
|
|
|
143 |
if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) {
|
|
|
144 |
return;
|
|
|
145 |
}
|
|
|
146 |
LOGDEB(("internfile: after ucomp: m_tdir %s, tfile %s\n",
|
|
|
147 |
m_tdir.c_str(), m_tfile.c_str()));
|
|
|
148 |
m_fn = m_tfile;
|
|
|
149 |
m_mime = mimetype(m_fn, m_cfg, usfci);
|
|
|
150 |
if (m_mime.empty() && imime)
|
|
|
151 |
m_mime = *imime;
|
|
|
152 |
if (m_mime.empty()) {
|
|
|
153 |
// No mime type ?? pass on.
|
|
|
154 |
LOGDEB(("internfile: (no mime) [%s]\n", m_fn.c_str()));
|
155 |
LOGDEB(("internfile: (no mime) [%s]\n", m_fn.c_str()));
|
155 |
return;
|
|
|
156 |
}
|
|
|
157 |
}
|
156 |
}
|
158 |
|
157 |
|
159 |
// Look for appropriate handler
|
158 |
// Look for appropriate handler (might still return empty)
|
160 |
m_handler = getMimeHandler(m_mime, m_cfg);
|
159 |
m_handler = getMimeHandler(m_mime, m_cfg);
|
|
|
160 |
|
161 |
if (!m_handler) {
|
161 |
if (!m_handler) {
|
162 |
// No handler for this type, for now :(
|
162 |
// No handler for this type, for now :( if indexallfilenames
|
|
|
163 |
// is set in the config, this normally wont happen (we get mh_unknown)
|
163 |
LOGDEB(("FileInterner::FileInterner: %s: no handler\n",
|
164 |
LOGDEB(("FileInterner::FileInterner: %s: no handler\n",
|
164 |
m_mime.c_str()));
|
165 |
m_mime.c_str()));
|
165 |
return;
|
166 |
return;
|
166 |
}
|
167 |
}
|
167 |
m_handler->setForPreview(forPreview);
|
168 |
m_handler->setForPreview(forPreview);
|