fileudi test driver: improve

This commit is contained in:
Jean-Francois Dockes 2020-08-06 15:58:46 +02:00
parent 0f36253565
commit 4576cf7285
3 changed files with 32 additions and 17 deletions

View File

@ -38,7 +38,7 @@ AM_CPPFLAGS = -Wall -Wno-unused -std=c++11 \
$(DEFS) $(DEFS)
noinst_PROGRAMS = textsplit utf8iter fstreewalk rclconfig hldata unac mbox \ noinst_PROGRAMS = textsplit utf8iter fstreewalk rclconfig hldata unac mbox \
circache wipedir mimetype pathut circache wipedir mimetype pathut fileudi
textsplit_SOURCES = trtextsplit.cpp textsplit_SOURCES = trtextsplit.cpp
textsplit_LDADD = ../librecoll.la textsplit_LDADD = ../librecoll.la
@ -52,6 +52,9 @@ mimetype_LDADD = ../librecoll.la
utf8iter_SOURCES = trutf8iter.cpp utf8iter_SOURCES = trutf8iter.cpp
utf8iter_LDADD = ../librecoll.la utf8iter_LDADD = ../librecoll.la
fileudi_SOURCES = trfileudi.cpp
fileudi_LDADD = ../librecoll.la
fstreewalk_SOURCES = trfstreewalk.cpp fstreewalk_SOURCES = trfstreewalk.cpp
fstreewalk_LDADD = ../librecoll.la fstreewalk_LDADD = ../librecoll.la

View File

@ -20,25 +20,37 @@
#include "fileudi.h" #include "fileudi.h"
#include <stdio.h> #include <string.h>
#include <iostream>
#include <string> #include <string>
using namespace std; using namespace std;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
string path="/usr/lib/toto.cpp"; if (argc > 3) {
string ipath = "1:2:3:4:5:10"; std::cerr << "Usage: trfileudi <path> [ipath]\n";
string udi; std::cerr << "Usage: trfileudi #reads stdin for paths\n";
make_udi(path, ipath, udi); return 1;
printf("udi [%s]\n", udi.c_str()); }
path = "/some/much/too/looooooooooooooong/path/bla/bla/bla" string udi;
"/looooooooooooooong/path/bla/bla/bla/llllllllllllllllll" if (argc == 1) {
"/looooooooooooooong/path/bla/bla/bla/llllllllllllllllll"; char buffer[2048];
ipath = "1:2:3:4:5:10" while (fgets(buffer, 2048, stdin)) {
"1:2:3:4:5:10" std::string path(buffer, strlen(buffer)-1);
"1:2:3:4:5:10"; make_udi(path, "", udi);
make_udi(path, ipath, udi); std::cout << udi << "\n";
printf("udi [%s]\n", udi.c_str()); }
return 0;
} else {
string path = argv[1];
string ipath;
if (argc == 3) {
ipath = argv[2];
}
make_udi(path, ipath, udi);
std::cout << udi << "\n";
return 0;
}
} }

View File

@ -16,8 +16,8 @@
*/ */
#include "autoconfig.h" #include "autoconfig.h"
#include <stdio.h>
#include <cstdlib> #include <cstdlib>
#include <iostream>
#include "fileudi.h" #include "fileudi.h"
#include "md5.h" #include "md5.h"
@ -34,7 +34,7 @@ using std::string;
void pathHash(const std::string &path, std::string &phash, unsigned int maxlen) void pathHash(const std::string &path, std::string &phash, unsigned int maxlen)
{ {
if (maxlen < HASHLEN) { if (maxlen < HASHLEN) {
fprintf(stderr, "pathHash: internal error: requested len too small\n"); std::cerr << "pathHash: internal error: requested len too small\n";
abort(); abort();
} }