#!/usr/bin/ruby-w
#
require'digest/md5'
ifARGV.empty?
puts"usgae:#$0path"
exit0
end
dir_name=ARGV.shift
defdir_md5sum(path)
md5s=Array.new
ifFile.directory?(path)
Dir.new(path).eachdo|file|
nextiffile=~/^\.+$/
file="#{path}/#{file}"
ifFile.directory?(file)
dir_md5sum(file)
elsifFile.file?(file)
md5="#{Digest::MD5.hexdigest(File.read(file))}#{file}"
md5s.push(md5)
end
end
elsifFile.file?(path)
md5="#{Digest::MD5.hexdigest(File.read(path))}#{path}"
md5s.push(md5)
else
puts"IvalidFiletype"
exit2
end
md5s.eachdo|item|
putsitem
end
end
dir_md5sum(dir_name)