comparison unique.d @ 703:8dc894322ce8

repos maintenance
author thomask
date Wed, 12 Oct 2005 18:24:50 +0000
parents fa8d1cf74ab8
children 5ba45899cddd
comparison
equal deleted inserted replaced
702:4c5b7f538994 703:8dc894322ce8
1 module cn.kuehne.uniquefile; 1 module cn.kuehne.uniquefile;
2 2
3 private import std.file; 3 private import std.file;
4 private import std.stdio; 4 private import std.stdio;
5 private import std.path; 5 private import std.path;
6
7 version(verbose){
8 FILE* msgStream = stderr;
9 }else{
10 FILE* msgStream = stdout;
11 }
12 6
13 private char[][char[]] known; 7 private char[][char[]] known;
14 private uint doppelgaenger; 8 private uint doppelgaenger;
15 9
16 private char[] lastPathElem(char[] path){ 10 private char[] lastPathElem(char[] path){
41 char[] base = lastPathElem(file); 35 char[] base = lastPathElem(file);
42 36
43 if(isfile(file)){ 37 if(isfile(file)){
44 char[]* tmp = base in known; 38 char[]* tmp = base in known;
45 if(tmp){ 39 if(tmp){
46 fwritef(msgStream, "%s :\n\t%s\n\t%s\n", base, file, *tmp); 40 fwritef(stdout, "%s :\n\t%s\n\t%s\n", base, file, *tmp);
47 doppelgaenger++; 41 doppelgaenger++;
48 }else{ 42 }else{
49 known[base] = file; 43 known[base] = file;
50 } 44 }
51 } 45 }
72 add(file); 66 add(file);
73 } 67 }
74 68
75 version(verbose){ 69 version(verbose){
76 foreach(char[] entry; known.keys.sort){ 70 foreach(char[] entry; known.keys.sort){
77 writef("\t%s\n", entry); 71 fwritef(stderr, "\t%s\n", entry);
78 } 72 }
79 } 73 }
80 74
81 fwritef(msgStream, "hits : %s\n", doppelgaenger); 75 fwritef(stdout, "hits : %s\n", doppelgaenger);
82 76
83 return doppelgaenger > 0; 77 return doppelgaenger > 0;
84 } 78 }