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
+6 -5
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.48 2006-12-16 15:30:32 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.49 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
@@ -344,7 +344,8 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
int abslen;
if (m_config->getConfParam("idxabsmlen", &abslen))
m_db.setAbstractParams(abslen, -1, -1);
return FsTreeWalker::FtwOk;
if (flg == FsTreeWalker::FtwDirReturn)
return FsTreeWalker::FtwOk;
}
// Check db up to date ? Doing this before file type
@@ -363,7 +364,7 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
return FsTreeWalker::FtwOk;
}
FileInterner interner(fn, m_config, m_tmpdir);
FileInterner interner(fn, stp, m_config, m_tmpdir);
// File name transcoded to utf8 for indexation.
string charset = m_config->getDefCharset(true);
@@ -427,8 +428,8 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
if (hadNullIpath == false) {
LOGDEB1(("Creating empty doc for file\n"));
Rcl::Doc fileDoc;
fileDoc.fmtime = doc.fmtime;
fileDoc.utf8fn = doc.utf8fn;
fileDoc.fmtime = ascdate;
fileDoc.utf8fn = utf8fn;
fileDoc.mimetype = interner.get_mimetype();
if (!m_db.add(fn, fileDoc, stp))
return FsTreeWalker::FtwError;
+19 -3
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.18 2006-12-11 14:50:53 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.19 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
@@ -19,6 +19,8 @@ static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.18 2006-12-11 14:50:53 dockes Ex
*/
#ifndef TEST_MIMETYPE
#include <sys/stat.h>
#include <ctype.h>
#include <string>
#include <list>
@@ -104,8 +106,14 @@ static string mimetypefromdata(const string &fn, bool usfc)
/// Guess mime type, first from suffix, then from file data. We also
/// have a list of suffixes that we don't touch at all (ie: .jpg,
/// etc...)
string mimetype(const string &fn, RclConfig *cfg, bool usfc)
string mimetype(const string &fn, const struct stat *stp,
RclConfig *cfg, bool usfc)
{
if (S_ISDIR(stp->st_mode))
return "application/x-fsdirectory";
if (!S_ISREG(stp->st_mode))
return "application/x-fsspecial";
if (cfg == 0)
return "";
@@ -140,7 +148,10 @@ string mimetype(const string &fn, RclConfig *cfg, bool usfc)
#else // TEST->
#include <stdio.h>
#include <sys/stat.h>
#include <iostream>
#include "debuglog.h"
@@ -163,8 +174,13 @@ int main(int argc, const char **argv)
while (--argc > 0) {
string filename = *++argv;
struct stat st;
if (stat(filename.c_str(), &st)) {
fprintf(stderr, "Can't stat %s\n", filename.c_str());
continue;
}
cout << filename << " -> " <<
mimetype(filename, config, true) << endl;
mimetype(filename, &st, config, true) << endl;
}
return 0;
+4 -3
View File
@@ -16,18 +16,19 @@
*/
#ifndef _MIMETYPE_H_INCLUDED_
#define _MIMETYPE_H_INCLUDED_
/* @(#$Id: mimetype.h,v 1.5 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: mimetype.h,v 1.6 2006-12-19 08:40:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
class RclConfig;
struct stat;
/**
* Try to determine a mime type for filename.
* This may imply more than matching the suffix, the name must be usable
* to actually access file data.
*/
string mimetype(const std::string &filename, RclConfig *cfg, bool usfc);
string mimetype(const std::string &filename, const struct stat *stp,
RclConfig *cfg, bool usfc);
#endif /* _MIMETYPE_H_INCLUDED_ */