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";
std::cerr << "Usage: trfileudi #reads stdin for paths\n";
return 1;
}
string udi; string udi;
make_udi(path, ipath, udi); if (argc == 1) {
printf("udi [%s]\n", udi.c_str()); char buffer[2048];
path = "/some/much/too/looooooooooooooong/path/bla/bla/bla" while (fgets(buffer, 2048, stdin)) {
"/looooooooooooooong/path/bla/bla/bla/llllllllllllllllll" std::string path(buffer, strlen(buffer)-1);
"/looooooooooooooong/path/bla/bla/bla/llllllllllllllllll"; make_udi(path, "", udi);
ipath = "1:2:3:4:5:10" std::cout << udi << "\n";
"1:2:3:4:5:10" }
"1:2:3:4:5:10"; return 0;
make_udi(path, ipath, udi); } else {
printf("udi [%s]\n", udi.c_str()); 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();
} }