pgup/down in result list

This commit is contained in:
dockes 2005-12-13 12:43:00 +00:00
parent 0122545ece
commit 52fa7836b7
17 changed files with 157 additions and 124 deletions

View File

@ -5,18 +5,21 @@
# $FreeBSD$ # $FreeBSD$
# #
PORTNAME= recoll PORTNAME= recoll
PORTVERSION= 1.0.13 PORTVERSION= 1.0.14
CATEGORIES= deskutils CATEGORIES= deskutils
MASTER_SITES= http://www.lesbonscomptes.com/recoll/ MASTER_SITES= http://www.lesbonscomptes.com/recoll/
MAINTAINER= jean-francois.dockes@wanadoo.fr MAINTAINER= jean-francois.dockes@wanadoo.fr
COMMENT= A personal full text search package, based on QT and Xapian COMMENT= A personal full text search package, based on QT and Xapian
LIB_DEPENDS= xapian.8:${PORTSDIR}/databases/xapian-core \ BUILD_DEPENDS= qmake:${PORTSDIR}/devel/qmake
qt-mt.3:${PORTSDIR}/x11-toolkits/qt33 LIB_DEPENDS= xapian.8:${PORTSDIR}/databases/xapian-core \
qt-mt.3:${PORTSDIR}/x11-toolkits/qt33
GNU_CONFIGURE= yes USE_QT_VER= 3
USE_GMAKE= yes MAKE_ENV= QTDIR="${QT_PREFIX}" QMAKESPEC="freebsd-g++"
GNU_CONFIGURE= yes
USE_GMAKE= yes
.include <bsd.port.mk> .include <bsd.port.mk>

View File

@ -1,3 +1,3 @@
MD5 (recoll-1.0.13.tar.gz) = b4fd87b467e25e8f6ec96e86a8196181 MD5 (recoll-1.0.14.tar.gz) = 223037883f26294405491e0e2c8ab33b
SHA256 (recoll-1.0.13.tar.gz) = d8407c5090a35e6196f4cef6b9f787f94e89a2746f995010b3b7ac6af9cb6bd7 SHA256 (recoll-1.0.14.tar.gz) = 0552c467c2c1c8eedc98a1fcc457304e29f080c2afe11fad5c55b88b4cf3548f
SIZE (recoll-1.0.13.tar.gz) = 328105 SIZE (recoll-1.0.14.tar.gz) = 328158

View File

@ -20,3 +20,5 @@ Features:
necessary. necessary.
* An indexer which runs either as a thread inside the GUI or as an * An indexer which runs either as a thread inside the GUI or as an
external, cron'able program. external, cron'able program.
WWW: http://www.lesbonscomptes.com/recoll/

View File

@ -1,30 +1,30 @@
bin/recoll bin/recoll
bin/recollindex bin/recollindex
share/recoll/examples/mimeconf %%DATADIR%%/examples/mimeconf
share/recoll/examples/mimemap %%DATADIR%%/examples/mimemap
share/recoll/examples/recoll.conf %%DATADIR%%/examples/recoll.conf
share/recoll/filters/rcldoc %%DATADIR%%/filters/rcldoc
share/recoll/filters/rclgaim %%DATADIR%%/filters/rclgaim
share/recoll/filters/rclpdf %%DATADIR%%/filters/rclpdf
share/recoll/filters/rclps %%DATADIR%%/filters/rclps
share/recoll/filters/rclrtf %%DATADIR%%/filters/rclrtf
share/recoll/filters/rclsoff %%DATADIR%%/filters/rclsoff
share/recoll/filters/rcluncomp %%DATADIR%%/filters/rcluncomp
share/recoll/images/document.png %%DATADIR%%/images/document.png
share/recoll/images/drawing.png %%DATADIR%%/images/drawing.png
share/recoll/images/html.png %%DATADIR%%/images/html.png
share/recoll/images/message.png %%DATADIR%%/images/message.png
share/recoll/images/mozilla_doc.png %%DATADIR%%/images/mozilla_doc.png
share/recoll/images/pdf.png %%DATADIR%%/images/pdf.png
share/recoll/images/postscript.png %%DATADIR%%/images/postscript.png
share/recoll/images/presentation.png %%DATADIR%%/images/presentation.png
share/recoll/images/soffice.png %%DATADIR%%/images/soffice.png
share/recoll/images/spreadsheet.png %%DATADIR%%/images/spreadsheet.png
share/recoll/images/txt.png %%DATADIR%%/images/txt.png
share/recoll/images/wordprocessing.png %%DATADIR%%/images/wordprocessing.png
share/recoll/translations/recoll_fr.qm %%DATADIR%%/translations/recoll_fr.qm
@dirrm share/recoll/examples @dirrm %%DATADIR%%/examples
@dirrm share/recoll/filters @dirrm %%DATADIR%%/filters
@dirrm share/recoll/images @dirrm %%DATADIR%%/images
@dirrm share/recoll/translations @dirrm %%DATADIR%%/translations
@dirrm share/recoll @dirrm %%DATADIR%%

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.16 2005-12-05 14:09:16 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.17 2005-12-13 12:42:59 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
@ -9,12 +9,11 @@ static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.16 2005-12-05 14:09:16 dockes E
#include <iostream> #include <iostream>
#include "rclconfig.h"
#include "pathut.h" #include "pathut.h"
#include "rclconfig.h"
#include "conftree.h" #include "conftree.h"
#include "debuglog.h" #include "debuglog.h"
#include "smallut.h" #include "smallut.h"
#include "pathut.h"
#include "copyfile.h" #include "copyfile.h"
#ifndef NO_NAMESPACES #ifndef NO_NAMESPACES
@ -29,8 +28,7 @@ static bool createConfig(string &reason)
const char *cprefix = getenv("RECOLL_PREFIX"); const char *cprefix = getenv("RECOLL_PREFIX");
if (cprefix == 0) if (cprefix == 0)
cprefix = RECOLL_PREFIX; cprefix = RECOLL_PREFIX;
string prefix(cprefix); string prefix = path_cat(cprefix, "share/recoll/examples");
path_cat(prefix, "share/recoll/examples");
string recolldir = path_tildexpand("~/.recoll"); string recolldir = path_tildexpand("~/.recoll");
if (mkdir(recolldir.c_str(), 0755) < 0) { if (mkdir(recolldir.c_str(), 0755) < 0) {
@ -39,10 +37,8 @@ static bool createConfig(string &reason)
return false; return false;
} }
for (int i = 0; i < ncffiles; i++) { for (int i = 0; i < ncffiles; i++) {
string src = prefix; string src = path_cat((const string&)prefix, string(configfiles[i]));
path_cat(src, string(configfiles[i])); string dst = path_cat((const string&)recolldir, string(configfiles[i]));
string dst = recolldir;
path_cat(dst, string(configfiles[i]));
if (!copyfile(src.c_str(), dst.c_str(), reason)) { if (!copyfile(src.c_str(), dst.c_str(), reason)) {
LOGERR(("Copyfile failed: %s\n", reason.c_str())); LOGERR(("Copyfile failed: %s\n", reason.c_str()));
return false; return false;
@ -70,8 +66,7 @@ RclConfig::RclConfig()
confdir = path_home(); confdir = path_home();
confdir += ".recoll/"; confdir += ".recoll/";
} }
string cfilename = confdir; string cfilename = path_cat(confdir, "recoll.conf");
path_cat(cfilename, "recoll.conf");
if (access(confdir.c_str(), 0) != 0 || access(cfilename.c_str(), 0) != 0) { if (access(confdir.c_str(), 0) != 0 || access(cfilename.c_str(), 0) != 0) {
if (!createConfig(reason)) if (!createConfig(reason))
@ -92,8 +87,7 @@ RclConfig::RclConfig()
if (!conf->get("mimemapfile", mimemapfile, "")) { if (!conf->get("mimemapfile", mimemapfile, "")) {
mimemapfile = "mimemap"; mimemapfile = "mimemap";
} }
string mpath = confdir; string mpath = path_cat(confdir, mimemapfile);
path_cat(mpath, mimemapfile);
mimemap = new ConfTree(mpath.c_str(), true); mimemap = new ConfTree(mpath.c_str(), true);
if (mimemap == 0 || if (mimemap == 0 ||
(mimemap->getStatus() != ConfSimple::STATUS_RO && (mimemap->getStatus() != ConfSimple::STATUS_RO &&
@ -108,8 +102,7 @@ RclConfig::RclConfig()
if (!conf->get("mimeconffile", mimeconffile, "")) { if (!conf->get("mimeconffile", mimeconffile, "")) {
mimeconffile = "mimeconf"; mimeconffile = "mimeconf";
} }
mpath = confdir; mpath = path_cat(confdir, mimeconffile);
path_cat(mpath, mimeconffile);
mimeconf = new ConfTree(mpath.c_str(), true); mimeconf = new ConfTree(mpath.c_str(), true);
if (mimeconf == 0 || if (mimeconf == 0 ||
(mimeconf->getStatus() != ConfSimple::STATUS_RO && (mimeconf->getStatus() != ConfSimple::STATUS_RO &&
@ -230,17 +223,15 @@ string find_filter(RclConfig *conf, const string &icmd)
const char *cp; const char *cp;
if (cp = getenv("RECOLL_FILTERSDIR")) { if (cp = getenv("RECOLL_FILTERSDIR")) {
cmd = cp; cmd = path_cat(cp, icmd);
path_cat(cmd, icmd);
if (access(cmd.c_str(), X_OK) == 0) if (access(cmd.c_str(), X_OK) == 0)
return cmd; return cmd;
} else if (conf->getConfParam(string("filtersdir"), cmd)) { } else if (conf->getConfParam(string("filtersdir"), cmd)) {
path_cat(cmd, icmd); cmd = path_cat(cmd, icmd);
if (access(cmd.c_str(), X_OK) == 0) if (access(cmd.c_str(), X_OK) == 0)
return cmd; return cmd;
} else { } else {
cmd = conf->getConfDir(); cmd = path_cat(conf->getConfDir(), icmd);
path_cat(cmd, icmd);
if (access(cmd.c_str(), X_OK) == 0) if (access(cmd.c_str(), X_OK) == 0)
return cmd; return cmd;
} }

View File

@ -606,7 +606,7 @@ GENERATE_HTML = YES
# If a relative path is entered the value of OUTPUT_DIRECTORY will be # If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path. # put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT = html HTML_OUTPUT = docprog_html
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for # The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # each generated HTML page (for example: .htm,.php,.asp). If it is left blank

View File

@ -1,5 +1,5 @@
documentation: documentation:
doxygen Doxyfile doxygen Doxyfile
clean: clean:
rm -f html/* rm -f docprog_html/*

View File

@ -22,7 +22,7 @@ external filter, which will probably be the simpler solution in most cases.
\section extfilts External filters \section extfilts External filters
Filters are programs (usually shell scripts) that will turn a document of Filters are programs (usually shell scripts) that will turn a document of
foreign type into something that Recoll can understand. Html was chosen as foreign type into something that Recoll can understand. HTML was chosen as
a pivot format for its ability to carry structured information. a pivot format for its ability to carry structured information.
The meta-information tags that Recoll will use at the moment are the The meta-information tags that Recoll will use at the moment are the
@ -33,15 +33,15 @@ following:
- keywords - keywords
- description - description
For an example, you can take a look, at rclsoff which translates openoffice For an example, you can take a look at the rclsoff filter which translates
documents. openoffice documents.
The filter is executed with the input file name as a parameter and should The filter is executed with the input file name as a parameter and should
output the result to stdout. output the result to stdout.
\section extassoc Associating a filter to a mime type \section extassoc Associating a filter to a mime type
This is done in mimeconf. Take a look at the file, the format is This is done in the mimeconf configuration file. Take a look at the file,
self-explanatory. the format is self-explanatory.
*/ */

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: main.cpp,v 1.21 2005-12-05 14:57:54 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: main.cpp,v 1.22 2005-12-13 12:42:59 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
#include <unistd.h> #include <unistd.h>
@ -38,6 +38,8 @@ bool showicons;
string iconsdir; string iconsdir;
RclDHistory *history; RclDHistory *history;
static string dbdir;
void getQueryStemming(bool &dostem, std::string &stemlang) void getQueryStemming(bool &dostem, std::string &stemlang)
{ {
string param; string param;
@ -51,20 +53,14 @@ void getQueryStemming(bool &dostem, std::string &stemlang)
bool maybeOpenDb(string &reason) bool maybeOpenDb(string &reason)
{ {
if (!rcldb) if (!rcldb) {
reason = "Internal error: db not created";
return false;
}
if (!rcldb->isopen() && !rcldb->open(dbdir, Rcl::Db::DbRO)) {
reason = "Could not open database in " +
dbdir + " wait for indexing to complete?";
return false; return false;
if (!rcldb->isopen()) {
string dbdir;
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
reason = "No db directory in configuration";
return false;
}
dbdir = path_tildexpand(dbdir);
if (!rcldb->open(dbdir, Rcl::Db::DbRO)) {
reason = "Could not open database in " +
dbdir + " wait for indexing to complete?";
return false;
}
} }
return true; return true;
} }
@ -134,7 +130,6 @@ int main( int argc, char ** argv )
exit(1); exit(1);
} }
string dbdir;
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) { if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
// Note: this will have to be replaced by a call to a // Note: this will have to be replaced by a call to a
// configuration buildin dialog for initial configuration // configuration buildin dialog for initial configuration
@ -143,10 +138,10 @@ int main( int argc, char ** argv )
"No db directory in configuration")); "No db directory in configuration"));
exit(1); exit(1);
} }
dbdir = path_tildexpand(dbdir);
// Translations for Recoll // Translations for Recoll
string translatdir = string(recollsharedir); string translatdir = path_cat(recollsharedir, "translations");
path_cat(translatdir, "translations");
QTranslator translator( 0 ); QTranslator translator( 0 );
// QTextCodec::locale() returns $LANG // QTextCodec::locale() returns $LANG
translator.load( QString("recoll_") + QTextCodec::locale(), translator.load( QString("recoll_") + QTextCodec::locale(),
@ -157,8 +152,7 @@ int main( int argc, char ** argv )
rclconfig->getConfParam("showicons", &showicons); rclconfig->getConfParam("showicons", &showicons);
rclconfig->getConfParam("iconsdir", iconsdir); rclconfig->getConfParam("iconsdir", iconsdir);
if (iconsdir.empty()) { if (iconsdir.empty()) {
iconsdir = string(recollsharedir); iconsdir = path_cat(recollsharedir, "images");
path_cat(iconsdir, "images");
} else { } else {
iconsdir = path_tildexpand(iconsdir); iconsdir = path_tildexpand(iconsdir);
} }
@ -170,11 +164,9 @@ int main( int argc, char ** argv )
exit(1); exit(1);
} }
string historyfile = rclconfig->getConfDir(); string historyfile = path_cat(rclconfig->getConfDir(), "history");
path_cat(historyfile, "history");
history = new RclDHistory(historyfile); history = new RclDHistory(historyfile);
dbdir = path_tildexpand(dbdir);
rcldb = new Rcl::Db; rcldb = new Rcl::Db;

View File

@ -398,6 +398,8 @@
<slot>reslistTE_delayedclick()</slot> <slot>reslistTE_delayedclick()</slot>
<slot>startSimpleSearch()</slot> <slot>startSimpleSearch()</slot>
<slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot> <slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot>
<slot>resPageUpOrBack()</slot>
<slot>resPageDownOrNext()</slot>
<slot>resultPageBack()</slot> <slot>resultPageBack()</slot>
<slot>showResultPage()</slot> <slot>showResultPage()</slot>
<slot>previewClosed( Preview * w )</slot> <slot>previewClosed( Preview * w )</slot>

View File

@ -66,7 +66,12 @@ void RecollMain::init()
sortform = 0; sortform = 0;
docsource = 0; docsource = 0;
sortwidth = 0; sortwidth = 0;
// We manage pgup/down, but let ie the arrows for the editor to process
reslistTE->installEventFilter(this);
reslistTE->viewport()->installEventFilter(this); reslistTE->viewport()->installEventFilter(this);
// reslistTE->viewport()->setFocusPolicy(QWidget::NoFocus);
} }
// We also want to get rid of the advanced search form and previews // We also want to get rid of the advanced search form and previews
@ -78,7 +83,8 @@ bool RecollMain::close(bool)
return false; return false;
} }
#if 0 //#define SHOWEVENTS
#if defined(SHOWEVENTS)
static const char *eventTypeToStr(int tp) static const char *eventTypeToStr(int tp)
{ {
switch (tp) { switch (tp) {
@ -167,12 +173,20 @@ static const char *eventTypeToStr(int tp)
// ^Q thing is necessary (we have an action for this)? // ^Q thing is necessary (we have an action for this)?
bool RecollMain::eventFilter( QObject * target, QEvent * event ) bool RecollMain::eventFilter( QObject * target, QEvent * event )
{ {
// LOGDEB(("RecollMain::eventFilter target %p, event %s\n", target, #if defined(SHOWEVENTS)
// eventTypeToStr(int(event->type())))); LOGDEB(("RecollMain::eventFilter target %p, event %s\n", target,
eventTypeToStr(int(event->type()))));
#endif
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = (QKeyEvent *)event; QKeyEvent *keyEvent = (QKeyEvent *)event;
if (keyEvent->key() == Key_Q && (keyEvent->state() & ControlButton)) { if (keyEvent->key() == Key_Q && (keyEvent->state() & ControlButton)) {
recollNeedsExit = 1; recollNeedsExit = 1;
} else if (keyEvent->key() == Key_Prior) {
resPageUpOrBack();
return true;
} else if (keyEvent->key() == Key_Next) {
resPageDownOrNext();
return true;
} }
} else if (target == reslistTE->viewport()) { } else if (target == reslistTE->viewport()) {
// We don't want btdown+drag+btup to be a click ! So monitor // We don't want btdown+drag+btup to be a click ! So monitor
@ -413,6 +427,28 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
showResultPage(); showResultPage();
} }
// Page Up/Down: we don't try to check if current paragraph is last or
// first. We just page up/down and check if viewport moved. If it did,
// fair enough, else we go to next/previous result page.
void RecollMain::resPageUpOrBack()
{
int vpos = reslistTE->contentsY();
reslistTE->moveCursor(QTextEdit::MovePgUp, false);
if (vpos == reslistTE->contentsY())
resultPageBack();
}
void RecollMain::resPageDownOrNext()
{
int vpos = reslistTE->contentsY();
reslistTE->moveCursor(QTextEdit::MovePgDown, false);
LOGDEB(("RecollMain::resPageDownOrNext: vpos before %d, after %d\n",
vpos, reslistTE->contentsY()));
if (vpos == reslistTE->contentsY())
showResultPage();
}
// Show previous page of results. We just set the current number back
// 2 pages and show next page.
void RecollMain::resultPageBack() void RecollMain::resultPageBack()
{ {
if (reslist_winfirst <= 0) if (reslist_winfirst <= 0)
@ -457,9 +493,15 @@ void RecollMain::showResultPage()
int last = MIN(resCnt-reslist_winfirst, respagesize); int last = MIN(resCnt-reslist_winfirst, respagesize);
string alltext;
// Insert results if any in result list window // Insert results if any in result list window. We have to send
// the text to the widgets, because we need the paragraph number
// each time we add a result paragraph (its diffult and
// error-prone to compute the paragraph numbers in parallel. We
// would like to disable updates while we're doing this, but
// couldn't find a way to make it work, the widget seems to become
// confused if appended while updates are disabled
// reslistTE->setUpdatesEnabled(false);
for (int i = 0; i < last; i++) { for (int i = 0; i < last; i++) {
string sh; string sh;
doc.erase(); doc.erase();
@ -477,13 +519,11 @@ void RecollMain::showResultPage()
QString line = "<p><font size=+1><b>"; QString line = "<p><font size=+1><b>";
line += docsource->title().c_str(); line += docsource->title().c_str();
line += "</b></font><br>"; line += "</b></font><br>";
//alltext.append(line.utf8());
reslistTE->append(line); reslistTE->append(line);
line = tr("<b>Displaying results starting at index" line = tr("<b>Displaying results starting at index"
" %1 (maximum set size %2)</b></p>\n") " %1 (maximum set size %2)</b></p>\n")
.arg(reslist_winfirst+1) .arg(reslist_winfirst+1)
.arg(resCnt); .arg(resCnt);
//alltext.append(line.utf8());
reslistTE->append(line); reslistTE->append(line);
} }
@ -544,7 +584,6 @@ void RecollMain::showResultPage()
"<i>" + doc.url + +"</i><br></p>\n"; "<i>" + doc.url + +"</i><br></p>\n";
QString str = QString::fromUtf8(result.c_str(), result.length()); QString str = QString::fromUtf8(result.c_str(), result.length());
//alltext.append(str.utf8());
reslistTE->append(str); reslistTE->append(str);
pageParaToReldocnums[reslistTE->paragraphs()-1] = i; pageParaToReldocnums[reslistTE->paragraphs()-1] = i;
@ -559,14 +598,16 @@ void RecollMain::showResultPage()
} else { } else {
// Restore first in win parameter that we shouln't have incremented // Restore first in win parameter that we shouln't have incremented
reslistTE->append(tr("<p>" reslistTE->append(tr("<p>"
/*"<img align=\"left\" source=\"myimage\">"*/ /*"<img align=\"left\" source=\"myimage\">"*/
"<b>No results found</b>" "<b>No results found</b>"
"<br>")); "<br>"));
reslist_winfirst -= respagesize; reslist_winfirst -= respagesize;
if (reslist_winfirst < 0) if (reslist_winfirst < 0)
reslist_winfirst = -1; reslist_winfirst = -1;
} }
//reslistTE->setUpdatesEnabled(true);reslistTE->sync();reslistTE->repaint();
#if 0 #if 0
{ {
FILE *fp = fopen("/tmp/reslistdebug", "w"); FILE *fp = fopen("/tmp/reslistdebug", "w");

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.43 2005-12-05 10:39:20 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.44 2005-12-13 12:42:59 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -501,8 +501,7 @@ bool Rcl::Db::needUpdate(const string &filename, const struct stat *stp)
/// Compute name of stem db for given base database and language /// Compute name of stem db for given base database and language
static string stemdbname(const string& basename, string lang) static string stemdbname(const string& basename, string lang)
{ {
string nm = basename; string nm = path_cat(basename, string("stem_") + lang);
path_cat(nm, string("stem_") + lang);
return nm; return nm;
} }

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.5 2005-11-24 07:16:16 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.6 2005-12-13 12:42:59 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#ifndef TEST_FSTREEWALK #ifndef TEST_FSTREEWALK
@ -128,8 +128,7 @@ FsTreeWalker::Status FsTreeWalker::walk(const string &top,
} }
{ {
string fn = top; string fn = path_cat(top, ent->d_name);
path_cat(fn, ent->d_name);
struct stat st; struct stat st;
int statret = (data->options & FtwFollow) ? stat(fn.c_str(), &st) : int statret = (data->options & FtwFollow) ? stat(fn.c_str(), &st) :

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.5 2005-11-24 07:16:16 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: pathut.cpp,v 1.6 2005-12-13 12:42:59 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#ifndef TEST_PATHUT #ifndef TEST_PATHUT
@ -12,6 +12,18 @@ static char rcsid[] = "@(#$Id: pathut.cpp,v 1.5 2005-11-24 07:16:16 dockes Exp $
using std::string; using std::string;
#endif /* NO_NAMESPACES */ #endif /* NO_NAMESPACES */
void path_catslash(std::string &s) {
if (s.empty() || s[s.length() - 1] != '/')
s += '/';
}
std::string path_cat(const std::string &s1, const std::string &s2) {
std::string res = s1;
path_catslash(res);
res += s2;
return res;
}
string path_getfather(const string &s) { string path_getfather(const string &s) {
string father = s; string father = s;

View File

@ -1,18 +1,11 @@
#ifndef _PATHUT_H_INCLUDED_ #ifndef _PATHUT_H_INCLUDED_
#define _PATHUT_H_INCLUDED_ #define _PATHUT_H_INCLUDED_
/* @(#$Id: pathut.h,v 1.3 2005-01-31 14:31:10 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: pathut.h,v 1.4 2005-12-13 12:42:59 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string> #include <string>
inline void path_catslash(std::string &s) { extern void path_catslash(std::string &s);
if (s.empty() || s[s.length() - 1] != '/') extern std::string path_cat(const std::string &s1, const std::string &s2);
s += '/';
}
inline void path_cat(std::string &s1, const std::string &s2) {
path_catslash(s1);
s1 += s2;
}
extern std::string path_getsimple(const std::string &s); extern std::string path_getsimple(const std::string &s);
extern std::string path_getfather(const std::string &s); extern std::string path_getfather(const std::string &s);
extern std::string path_home(); extern std::string path_home();

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.10 2005-11-25 14:36:45 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: smallut.cpp,v 1.11 2005-12-13 12:43:00 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#ifndef TEST_SMALLUT #ifndef TEST_SMALLUT
#include <string> #include <string>
@ -27,8 +27,8 @@ bool maketmpdir(string& tdir)
tmpdir = getenv("TMPDIR"); tmpdir = getenv("TMPDIR");
if (!tmpdir) if (!tmpdir)
tmpdir = "/tmp"; tmpdir = "/tmp";
tdir = tmpdir; tdir = path_cat(tmpdir, "rcltmpXXXXXX");
path_cat(tdir, "rcltmpXXXXXX");
{ {
char *cp = strdup(tdir.c_str()); char *cp = strdup(tdir.c_str());
if (!cp) { if (!cp) {

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: wipedir.cpp,v 1.3 2005-11-24 07:16:16 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: wipedir.cpp,v 1.4 2005-12-13 12:43:00 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#ifndef TEST_WIPEDIR #ifndef TEST_WIPEDIR
@ -50,8 +50,7 @@ int wipedir(const string& dir)
if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
continue; continue;
string fn = dir; string fn = path_cat(dir, ent->d_name);
path_cat(fn, ent->d_name);
struct stat st; struct stat st;
int statret = stat(fn.c_str(), &st); int statret = stat(fn.c_str(), &st);