|
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.9 2005-11-18 15:19:14 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.10 2005-11-21 14:31:24 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
#include <unistd.h>
|
4 |
#include <unistd.h>
|
5 |
#include <sys/types.h>
|
5 |
#include <sys/types.h>
|
6 |
#include <sys/stat.h>
|
6 |
#include <sys/stat.h>
|
7 |
#include <errno.h>
|
7 |
#include <errno.h>
|
|
... |
|
... |
100 |
|
100 |
|
101 |
bool forPreview = imime ? true : false;
|
101 |
bool forPreview = imime ? true : false;
|
102 |
|
102 |
|
103 |
// We need to run mime type identification in any case to check
|
103 |
// We need to run mime type identification in any case to check
|
104 |
// for a compressed file.
|
104 |
// for a compressed file.
|
105 |
m_mime = mimetype(m_fn, m_cfg->getMimeMap(), usfci);
|
105 |
m_mime = mimetype(m_fn, m_cfg, usfci);
|
106 |
|
106 |
|
107 |
// If identification fails, try to use the input parameter. Note that this
|
107 |
// If identification fails, try to use the input parameter. Note that this
|
108 |
// is normally not a compressed type (it's the mime type from the db)
|
108 |
// is normally not a compressed type (it's the mime type from the db)
|
109 |
if (m_mime.empty() && imime)
|
109 |
if (m_mime.empty() && imime)
|
110 |
m_mime = *imime;
|
110 |
m_mime = *imime;
|
|
... |
|
... |
116 |
|
116 |
|
117 |
// First check for a compressed file. If so, create a temporary
|
117 |
// First check for a compressed file. If so, create a temporary
|
118 |
// uncompressed file, and rerun the mime type identification, then do the
|
118 |
// uncompressed file, and rerun the mime type identification, then do the
|
119 |
// rest with the temp file.
|
119 |
// rest with the temp file.
|
120 |
list<string>ucmd;
|
120 |
list<string>ucmd;
|
121 |
if (getUncompressor(m_mime, m_cfg->getMimeConf(), ucmd)) {
|
121 |
if (m_cfg->getUncompressor(m_mime, ucmd)) {
|
122 |
if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) {
|
122 |
if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) {
|
123 |
return;
|
123 |
return;
|
124 |
}
|
124 |
}
|
125 |
LOGDEB(("internfile: after ucomp: m_tdir %s, tfile %s\n",
|
125 |
LOGDEB(("internfile: after ucomp: m_tdir %s, tfile %s\n",
|
126 |
m_tdir.c_str(), m_tfile.c_str()));
|
126 |
m_tdir.c_str(), m_tfile.c_str()));
|
127 |
m_fn = m_tfile;
|
127 |
m_fn = m_tfile;
|
128 |
m_mime = mimetype(m_fn, m_cfg->getMimeMap(), usfci);
|
128 |
m_mime = mimetype(m_fn, m_cfg, usfci);
|
129 |
if (m_mime.empty() && imime)
|
129 |
if (m_mime.empty() && imime)
|
130 |
m_mime = *imime;
|
130 |
m_mime = *imime;
|
131 |
if (m_mime.empty()) {
|
131 |
if (m_mime.empty()) {
|
132 |
// No mime type ?? pass on.
|
132 |
// No mime type ?? pass on.
|
133 |
LOGDEB(("internfile: (no mime) [%s]\n", m_fn.c_str()));
|
133 |
LOGDEB(("internfile: (no mime) [%s]\n", m_fn.c_str()));
|
134 |
return;
|
134 |
return;
|
135 |
}
|
135 |
}
|
136 |
}
|
136 |
}
|
137 |
|
137 |
|
138 |
// Look for appropriate handler
|
138 |
// Look for appropriate handler
|
139 |
m_handler = getMimeHandler(m_mime, m_cfg->getMimeConf());
|
139 |
m_handler = getMimeHandler(m_mime, m_cfg);
|
140 |
if (!m_handler) {
|
140 |
if (!m_handler) {
|
141 |
// No handler for this type, for now :(
|
141 |
// No handler for this type, for now :(
|
142 |
LOGDEB(("FileInterner::FileInterner: %s: no handler\n",
|
142 |
LOGDEB(("FileInterner::FileInterner: %s: no handler\n",
|
143 |
m_mime.c_str()));
|
143 |
m_mime.c_str()));
|
144 |
return;
|
144 |
return;
|