fileudi test driver: improve
This commit is contained in:
parent
0f36253565
commit
4576cf7285
@ -38,7 +38,7 @@ AM_CPPFLAGS = -Wall -Wno-unused -std=c++11 \
|
||||
$(DEFS)
|
||||
|
||||
noinst_PROGRAMS = textsplit utf8iter fstreewalk rclconfig hldata unac mbox \
|
||||
circache wipedir mimetype pathut
|
||||
circache wipedir mimetype pathut fileudi
|
||||
|
||||
textsplit_SOURCES = trtextsplit.cpp
|
||||
textsplit_LDADD = ../librecoll.la
|
||||
@ -52,6 +52,9 @@ mimetype_LDADD = ../librecoll.la
|
||||
utf8iter_SOURCES = trutf8iter.cpp
|
||||
utf8iter_LDADD = ../librecoll.la
|
||||
|
||||
fileudi_SOURCES = trfileudi.cpp
|
||||
fileudi_LDADD = ../librecoll.la
|
||||
|
||||
fstreewalk_SOURCES = trfstreewalk.cpp
|
||||
fstreewalk_LDADD = ../librecoll.la
|
||||
|
||||
|
||||
@ -20,25 +20,37 @@
|
||||
|
||||
#include "fileudi.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
string path="/usr/lib/toto.cpp";
|
||||
string ipath = "1:2:3:4:5:10";
|
||||
if (argc > 3) {
|
||||
std::cerr << "Usage: trfileudi <path> [ipath]\n";
|
||||
std::cerr << "Usage: trfileudi #reads stdin for paths\n";
|
||||
return 1;
|
||||
}
|
||||
string udi;
|
||||
make_udi(path, ipath, udi);
|
||||
printf("udi [%s]\n", udi.c_str());
|
||||
path = "/some/much/too/looooooooooooooong/path/bla/bla/bla"
|
||||
"/looooooooooooooong/path/bla/bla/bla/llllllllllllllllll"
|
||||
"/looooooooooooooong/path/bla/bla/bla/llllllllllllllllll";
|
||||
ipath = "1:2:3:4:5:10"
|
||||
"1:2:3:4:5:10"
|
||||
"1:2:3:4:5:10";
|
||||
make_udi(path, ipath, udi);
|
||||
printf("udi [%s]\n", udi.c_str());
|
||||
if (argc == 1) {
|
||||
char buffer[2048];
|
||||
while (fgets(buffer, 2048, stdin)) {
|
||||
std::string path(buffer, strlen(buffer)-1);
|
||||
make_udi(path, "", udi);
|
||||
std::cout << udi << "\n";
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "fileudi.h"
|
||||
#include "md5.h"
|
||||
@ -34,7 +34,7 @@ using std::string;
|
||||
void pathHash(const std::string &path, std::string &phash, unsigned int maxlen)
|
||||
{
|
||||
if (maxlen < HASHLEN) {
|
||||
fprintf(stderr, "pathHash: internal error: requested len too small\n");
|
||||
std::cerr << "pathHash: internal error: requested len too small\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user