sample/fullpath.rb


DEFINITIONS

This source file includes following functions.


   1  #! /usr/local/bin/ruby
   2  # convert ls-lR filename into fullpath.
   3  
   4  if ARGV[0] =~ /-p/
   5    ARGV.shift
   6    path = ARGV.shift 
   7  end
   8  
   9  if path == nil
  10    path = ""
  11  elsif path !~ %r|/$|
  12    path += "/"
  13  end
  14  
  15  while line = gets()
  16    case line
  17    when /:$/
  18      path = $_.chop.chop + "/"
  19    when /^total/, /^d/
  20    when /^(.*\d )(.+)$/
  21      print($1, path, $2, "\n")
  22    end
  23  end