diff doodle/utils/prog/md5_test.d @ 115:d7330cc52622

Added instructions to duplicates.d on the smallest changes required to trigger/untrigger the memory blowout. Interestingly the blowout only occurs when compiled with -m32, not -m64.
author David Bryant <bagnose@gmail.com>
date Sat, 16 Apr 2011 19:48:33 +0930
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doodle/utils/prog/md5_test.d	Sat Apr 16 19:48:33 2011 +0930
@@ -0,0 +1,39 @@
+import std.md5;
+import std.stdio;
+import std.file;
+import std.exception;
+
+int main(in string[] args) {
+    ulong file_count = 0;
+
+    foreach (string dir; args[1..$]) {
+        foreach (string name; dirEntries(dir, SpanMode.depth, false)) {
+            try {
+                ubyte[16] digest;
+
+                //writefln("Doing file: %s", name);
+                ++file_count;
+                writef("\rFile num: %s  ", file_count);
+
+                auto file = File(name, "r");
+                scope(exit) file.close;
+
+                MD5_CTX context;
+                context.start();
+                foreach (ubyte[] buffer; chunks(file, 4096 * 1024)) {
+                    //bytes_chewed(buffer.length);
+                    context.update(buffer);
+                }
+                context.finish(digest);
+            }
+            catch (FileException ex) {
+                writefln("File exception: %s", name);
+            }
+            catch (ErrnoException ex) {
+                writefln("Errno exception: %s", name);
+            }
+        }
+    }
+
+    return 0;
+}