Prepared windows port by removing a number of spurious reference to unix-specific interfaces, and using some xapian posix adaptor includes
This commit is contained in:
@@ -19,11 +19,11 @@
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include "safefcntl.h"
|
||||
#include <sys/types.h>
|
||||
#include "safesysstat.h"
|
||||
#include "safeunistd.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@@ -1117,7 +1117,7 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include "safesysstat.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "safesysstat.h"
|
||||
#include <time.h>
|
||||
#include <regex.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
@@ -272,9 +270,15 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
|
||||
// perror("fcntl");
|
||||
}
|
||||
#endif
|
||||
fseek((FILE *)m_vfp, 0, SEEK_END);
|
||||
m_fsize = ftell((FILE*)m_vfp);
|
||||
fseek((FILE*)m_vfp, 0, SEEK_SET);
|
||||
// Used to use ftell() here: no good beyond 2GB
|
||||
{struct stat st;
|
||||
if (fstat(fileno((FILE*)m_vfp), &st) < 0) {
|
||||
LOGERR(("MimeHandlerMbox:setdocfile: fstat(%s) failed errno %d\n",
|
||||
fn.c_str(), errno));
|
||||
return false;
|
||||
}
|
||||
m_fsize = st.st_size;
|
||||
}
|
||||
m_havedoc = true;
|
||||
m_offsets.clear();
|
||||
m_quirks = 0;
|
||||
|
||||
@@ -17,15 +17,11 @@
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#ifndef NO_NAMESPACES
|
||||
using namespace std;
|
||||
#endif /* NO_NAMESPACES */
|
||||
|
||||
#include "cstr.h"
|
||||
#include "mh_text.h"
|
||||
@@ -34,6 +30,7 @@ using namespace std;
|
||||
#include "md5ut.h"
|
||||
#include "rclconfig.h"
|
||||
#include "pxattr.h"
|
||||
#include "pathut.h"
|
||||
|
||||
const int MB = 1024*1024;
|
||||
const int KB = 1024;
|
||||
@@ -47,8 +44,8 @@ bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
|
||||
m_fn = fn;
|
||||
|
||||
// file size for oversize check
|
||||
struct stat st;
|
||||
if (stat(m_fn.c_str(), &st) < 0) {
|
||||
long long fsize = path_filesize(m_fn);
|
||||
if (fsize < 0) {
|
||||
LOGERR(("MimeHandlerText::set_document_file: stat(%s) errno %d\n",
|
||||
m_fn.c_str(), errno));
|
||||
return false;
|
||||
@@ -62,7 +59,7 @@ bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
|
||||
int maxmbs = 20;
|
||||
m_config->getConfParam("textfilemaxmbs", &maxmbs);
|
||||
|
||||
if (maxmbs == -1 || st.st_size / MB <= maxmbs) {
|
||||
if (maxmbs == -1 || fsize / MB <= maxmbs) {
|
||||
// Text file page size: if set, we split text files into
|
||||
// multiple documents
|
||||
int ps = 1000;
|
||||
|
||||
@@ -18,14 +18,10 @@
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
using std::map;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#include "uncomp.h"
|
||||
#include "debuglog.h"
|
||||
@@ -33,6 +29,10 @@ using std::vector;
|
||||
#include "execmd.h"
|
||||
#include "pathut.h"
|
||||
|
||||
using std::map;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
Uncomp::UncompCache Uncomp::o_cache;
|
||||
|
||||
bool Uncomp::uncompressfile(const string& ifn,
|
||||
@@ -70,8 +70,8 @@ bool Uncomp::uncompressfile(const string& ifn,
|
||||
m_dir->dirname()));
|
||||
// Hope for the best
|
||||
} else {
|
||||
struct stat stb;
|
||||
if (stat(ifn.c_str(), &stb) < 0) {
|
||||
long long fsize = path_filesize(ifn);
|
||||
if (fsize < 0) {
|
||||
LOGERR(("uncompressfile: stat input file %s errno %d\n",
|
||||
ifn.c_str(), errno));
|
||||
return false;
|
||||
@@ -82,7 +82,7 @@ bool Uncomp::uncompressfile(const string& ifn,
|
||||
// have enough space before trying. We take a little margin
|
||||
|
||||
// use same Mb def as fsocc()
|
||||
long long filembs = stb.st_size / (1024 * 1024);
|
||||
long long filembs = fsize / (1024 * 1024);
|
||||
|
||||
if (availmbs < 2 * filembs + 1) {
|
||||
LOGERR(("uncompressfile. %lld MBs available in %s not enough "
|
||||
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
|
||||
private:
|
||||
TempDir *m_dir;
|
||||
string m_tfile;
|
||||
string m_srcpath;
|
||||
std::string m_tfile;
|
||||
std::string m_srcpath;
|
||||
bool m_docache;
|
||||
|
||||
class UncompCache {
|
||||
@@ -59,8 +59,8 @@ private:
|
||||
}
|
||||
PTMutexInit m_lock;
|
||||
TempDir *m_dir;
|
||||
string m_tfile;
|
||||
string m_srcpath;
|
||||
std::string m_tfile;
|
||||
std::string m_srcpath;
|
||||
};
|
||||
static UncompCache o_cache;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user