|
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.2 2005-02-09 12:07:29 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.3 2005-03-17 15:35:49 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>
|
|
... |
|
... |
16 |
#include "mimehandler.h"
|
16 |
#include "mimehandler.h"
|
17 |
#include "execmd.h"
|
17 |
#include "execmd.h"
|
18 |
#include "pathut.h"
|
18 |
#include "pathut.h"
|
19 |
#include "wipedir.h"
|
19 |
#include "wipedir.h"
|
20 |
|
20 |
|
|
|
21 |
// Execute the command to uncompress a file into a temporary one.
|
21 |
static bool uncompressfile(RclConfig *conf, const string& ifn,
|
22 |
static bool uncompressfile(RclConfig *conf, const string& ifn,
|
22 |
const list<string>& cmdv, const string& tdir,
|
23 |
const list<string>& cmdv, const string& tdir,
|
23 |
string& tfile)
|
24 |
string& tfile)
|
24 |
{
|
25 |
{
|
25 |
// Make sure tmp dir is empty. we guarantee this to filters
|
26 |
// Make sure tmp dir is empty. we guarantee this to filters
|
|
... |
|
... |
93 |
// No mime type: not listed in our map.
|
94 |
// No mime type: not listed in our map.
|
94 |
LOGDEB(("internfile: (no mime) [%s]\n", fn.c_str()));
|
95 |
LOGDEB(("internfile: (no mime) [%s]\n", fn.c_str()));
|
95 |
return false;
|
96 |
return false;
|
96 |
}
|
97 |
}
|
97 |
|
98 |
|
98 |
// First check for a compressed file
|
99 |
// First check for a compressed file. If so, create a temporary
|
|
|
100 |
// uncompressed file, and rerun the mime type identification, then do the
|
|
|
101 |
// rest with the temp file.
|
99 |
list<string>ucmd;
|
102 |
list<string>ucmd;
|
100 |
if (getUncompressor(mime, config->getMimeConf(), ucmd)) {
|
103 |
if (getUncompressor(mime, config->getMimeConf(), ucmd)) {
|
101 |
if (!uncompressfile(config, fn, ucmd, tdir, tfile))
|
104 |
if (!uncompressfile(config, fn, ucmd, tdir, tfile))
|
102 |
return false;
|
105 |
return false;
|
103 |
LOGDEB(("internfile: after ucomp: tdir %s, tfile %s\n",
|
106 |
LOGDEB(("internfile: after ucomp: tdir %s, tfile %s\n",
|
|
... |
|
... |
110 |
goto out;
|
113 |
goto out;
|
111 |
}
|
114 |
}
|
112 |
|
115 |
|
113 |
}
|
116 |
}
|
114 |
|
117 |
|
|
|
118 |
|
115 |
// Look for appropriate handler
|
119 |
// Look for appropriate handler
|
116 |
handler = getMimeHandler(mime, config->getMimeConf());
|
120 |
handler = getMimeHandler(mime, config->getMimeConf());
|
117 |
if (!handler) {
|
121 |
if (!handler) {
|
118 |
// No handler for this type, for now :(
|
122 |
// No handler for this type, for now :(
|
119 |
LOGDEB(("internfile: %s : no handler\n", mime.c_str()));
|
123 |
LOGDEB(("internfile: %s : no handler\n", mime.c_str()));
|