diff bin/index2 @ 138:f963d52c031a

Merge.
author Edho Arief <edho@myconan.net>
date Wed, 02 Nov 2011 22:12:16 +0700
parents 5bafb912837e
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/index2	Wed Nov 02 22:12:16 2011 +0700
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Index version 2! Much better than first one. Hopefully.
+
+# Execute safely.
+safe_path()
+{
+	__start=$(printf "%s" | cut -c 1)
+	__path=
+	case "${__start}" in
+		.|/) __path="$*";;
+		*) __path="./$*";;
+	esac
+	printf "%s" "${__path}"
+}
+
+get_basename() { basename "$(safe_path "$*")"; }
+get_basename_pipe() { sed -e 's#.*/\([/]*\)$#\1#'; }
+
+filename_hash()
+{
+	printf "%s" "$(get_basename "$*")" 
+}
+generate_table_of_files()
+{
+	filetable_generator "$@"
+}
+filetable_generator()
+{
+	# Uses perl for speed.
+	perl -e 'use File::Find;
+use Digest::SHA1 qw(sha1_hex);
+use_warnings;
+use_strict;
+sub printer { printf("%s\n", sha1_hex($_)) if(-e && -f && !-l); } 
+find(\&printer, @ARGV);' "$@"
+}
+_srcdir=.
+generate_table_of_files "$@"