move ipath computations from reslist to internfile

This commit is contained in:
dockes
2008-08-26 07:33:05 +00:00
parent d6636e2597
commit 353ddb9a96
3 changed files with 40 additions and 23 deletions
+25 -2
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.38 2008-05-27 05:40:58 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.39 2008-08-26 07:33:05 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -47,6 +47,24 @@ using namespace std;
// file to ipath separator : "|"
static const string isep(":");
bool FileInterner::getEnclosing(const string &url, const string &ipath,
string &eurl, string &eipath)
{
eurl = url;
eipath = ipath;
string::size_type colon;
LOGDEB(("FileInterner::getEnclosing(): [%s]\n", eipath.c_str()));
if (eipath.empty())
return false;
if ((colon = eipath.find_last_of(isep)) != string::npos) {
eipath.erase(colon);
} else {
eipath.erase();
}
LOGDEB(("FileInterner::getEnclosing() after: [%s]\n", eipath.c_str()));
return true;
}
// Execute the command to uncompress a file into a temporary one.
static bool uncompressfile(RclConfig *conf, const string& ifn,
const list<string>& cmdv, const string& tdir,
@@ -610,6 +628,11 @@ Usage(void)
static int op_flags;
#define OPT_q 0x1
RclConfig *config;
RclConfig *RclConfig::getMainConfig()
{
return config;
}
int main(int argc, char **argv)
{
thisprog = argv[0];
@@ -639,7 +662,7 @@ int main(int argc, char **argv)
argc--;
}
string reason;
RclConfig *config = recollinit(0, 0, reason);
config = recollinit(0, 0, reason);
if (config == 0 || !config->ok()) {
string str = "Configuration problem: ";
+9 -2
View File
@@ -16,7 +16,7 @@
*/
#ifndef _INTERNFILE_H_INCLUDED_
#define _INTERNFILE_H_INCLUDED_
/* @(#$Id: internfile.h,v 1.16 2007-06-26 16:09:19 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: internfile.h,v 1.17 2008-08-26 07:33:05 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <vector>
@@ -39,7 +39,14 @@ struct stat;
*/
class FileInterner {
public:
/**
* Get immediate parent for document.
*
* This is not in general the same as the "parent" document used
* with Rcl::Db::addOrUpdate(). The latter is generally the enclosing file.
*/
static bool getEnclosing(const string &url, const string &ipath,
string &eurl, string &eipath);
/**
* Identify and possibly decompress file, create adequate
* handler. The mtype parameter is only set when the object is