call (Archive::Tar::Minitar::Command::CommandList)

         # File lib/archive/tar/minitar/command.rb, line 638
    638:     def call(args, opts = {}, ioe = {})
    639:       argv    = []
    640:       output  = nil
    641:       dest    = "."
    642:       files   = []
    643:       opts[:field] = "name"
    644:
    645:       while (arg = args.shift)
    646:         case arg
    647:         when '--sort', '-S'
    648:           opts[:sort]   = true
    649:           opts[:field]  = args.shift
    650:         when '--reverse', '-R'
    651:           opts[:reverse] = true
    652:           opts[:sort]    = true
    653:         when '--uncompress', '-z'
    654:           opts[:uncompress] = true
    655:         when '-l'
    656:           opts[:verbose] = true
    657:         else
    658:           argv << arg
    659:         end
    660:       end
    661:
    662:       if argv.size < 1
    663:         ioe[:output] << "Not enough arguments.\n\n"
    664:         CommandPattern["help"][["list"]]
    665:         return 255
    666:       end
    667:
    668:       input = argv.shift
    669:       if '-' == input
    670:         opts[:name] = "STDIN"
    671:         input = ioe[:input]
    672:       else
    673:         opts[:name] = input
    674:         input = File.open(input, "rb")
    675:       end
    676:
    677:       if opts[:name] =~ /\.tar\.gz$|\.tgz$/ or opts[:uncompress]
    678:         input = Zlib::GzipReader.new(input)
    679:       end
    680:
    681:       files << argv.to_a
    682:       files.flatten!
    683:
    684:       if opts[:verbose] or opts[:progress]
    685:         format  = "%10s %4d %8s %8s %8d %12s %s"
    686:         datefmt = "%b %d  %Y"
    687:         timefmt = "%b %d %H:%M"
    688:         fields  = %w(permissions inodes user group size date fullname)
    689:       else
    690:         format  = "%s"
    691:         fields  = %w(fullname)
    692:       end
    693:
    694:       opts[:field] = opts[:field].intern
    695:       opts[:field] = :full_name if opts[:field] == :name
    696:
    697:       output = []
    698:
    699:       Archive::Tar::Minitar::Input.open(input) do |inp|
    700:         today = Time.now
    701:         oneyear = Time.mktime(today.year - 1, today.month, today.day)
    702:         inp.each do |entry|
    703:           value = format % fields.map do |ff|
    704:             case ff
    705:             when "permissions"
    706:               s = entry.directory? ? "d" : "-"
    707:               s << modestr(entry.mode / 0100)
    708:               s << modestr(entry.mode / 0010)
    709:               s << modestr(entry.mode)
    710:             when "inodes"
    711:               entry.size / 512
    712:             when "user"
    713:               entry.uname || entry.uid || 0
    714:             when "group"
    715:               entry.gname || entry.gid || 0
    716:             when "size"
    717:               entry.size
    718:             when "date"
    719:               if Time.at(entry.mtime) > (oneyear)
    720:                 Time.at(entry.mtime).strftime(timefmt)
    721:               else
    722:                 Time.at(entry.mtime).strftime(datefmt)
    723:               end
    724:             when "fullname"
    725:               entry.full_name
    726:             end
    727:           end
    728:
    729:           if opts[:sort]
    730:             output << [entry.send(opts[:field]), value]
    731:           else
    732:             ioe[:output] << value << "\n"
    733:           end
    734:
    735:         end
    736:       end
    737:
    738:       if opts[:sort]
    739:         output = output.sort { |a, b| a[0] <=> b[0] }
    740:         if opts[:reverse]
    741:           output.reverse_each { |oo| ioe[:output] << oo[1] << "\n" }
    742:         else
    743:           output.each { |oo| ioe[:output] << oo[1] << "\n" }
    744:         end
    745:       end
    746:
    747:       0
    748:     end